io - c++ program suddenly stopped writing to file -


i have little c++ programming experience, , wrote quick program find groups of links in long link list.

i have been using program last 2 days , worked fine (i'm guessing inefficiently, worked). stopped writing file. made new file , changed file name in program check corruption still isn't working. have identical program searching through separate link list, , program still working.

here code: i've gotten program write file checking strings while loop, instead of loop

#include <iostream> #include <fstream> #include <string>   int main() {     std::string string;     std::string findstring;     std::string line;     std::ifstream infile;      std::cout<<"find string: ";     std::getline(std::cin, findstring, '\n');      infile.open("old.rtf");     std::ofstream returnfile("return.txt");      int = 0;     std::string previousline = "";      while(a < 1)     {         std::getline(infile, string);         while(string != previousline &&  string.find(findstring) != std::string::npos)         {                     previousline = string;                     returnfile<<string<<"\n";                     std::cout<<string<<std::endl;         }     }     infile.close();     std::system("pause");     return 0; } 

i'm compiling using g++ on mac (running mountain lion)

thanks help!

it seems issue might related infinite loop.

int = 0; std::string previousline = "";  while(a < 1) {     // needs incremented in here or loop forever! } 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -