If anyone has C++ code that reads an input string one character at a time, I would appreciate it if you would post it.
I would like to see if I can read in a file and strip out the carriage returns from it.
Thank you.
Printable View
If anyone has C++ code that reads an input string one character at a time, I would appreciate it if you would post it.
I would like to see if I can read in a file and strip out the carriage returns from it.
Thank you.
Hmm I did have something like that that I wrote a while ago, but I think I've formatted my hard disk since then. Ah well, here's the jist of it:
Code:char *path = "c:\\yourpath\\yourfile.txt";
FILE *fp = fopen(path, "r"); // "r" means open for reading
//you should check for a NULL pointer here, which
//means the fopen() failed
char currentChar;
while(!feof(fp)) //while not end-of-file
{ currentChar = fgetc(fp);
//do something with your character here
};
fclose(fp); //close your file once you're finished
Thanks a lot !
I will give your code here and your suggestion in the other thread a try.