stop when the character appears second time while file reading + components for graph C++ -


Hello I have a small problem, I am trying to load from one file to another. Here's the problem: The infile graph contains: some graph: some 2 etc. And I just need to load that some (between graph and graph), but another file can not be written graph: only some .

And later I need to count the components of the graph, I already have the function to calculate the components of the graph, but only load me a graph, then write the component, clear it Do it and load another and etc. That file has 9 graphs. Any thoughts? Here is my code:

  zero load 2 () {ifstream infile; Infile.open ("graph.txt"); // Input File Offline Outfile; Outfile.open ("out.txt"); // While output file (! Infile.eof ()) {char c = infile.get (); If (c == 'g') {break; } While (! Infile.eof ()) {char c = infile.get (); If (c == 'g') {for (int i = 0; i & lt; 6; i ++) {// Delete 6 characters are included in the graph infile & gt; & Gt; C; }} Outfile & lt; & Lt; C; }} Infile.close (); outfile.close ();    

Assume that graphs: and some < / Code> is separated from white space

  zero load 2 () {ifstream infile ("graph.txt"); Outstream Outfill ("Out TTT"); Std :: string graph, some; While (Infelix> gt; graph & gt; & gt; some) {if (graph! = "Graph:") {break; } Outfile & lt; & Lt; something; }}   

The following should handle the format explained in your comment

  std :: string token; While (infile & gt; token) {if (token! = "Graph:") {outfile & lt; & Lt; Token; }}    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -