Mail Archives: djgpp/1998/05/13/04:18:13
I'm slowly learning c++. Have gone through some c tutorials etc and am
currently going through a few c++ ones.
Writing a little program of my own to learn along the way. Started
doing it in c and would now like to convert it to c++.
It involves reading from a text file, looking for certain words and
extracting dates, numbers etc..
In C it uses:
fp1 = fopen("modemlog.txt", "r");
if (fp1 == NULL)
{
printf("File failed open");
exit (EXIT_FAILURE);
}
to open the file for reading, how do I change this to the c++ way?
c = fgets(line, 100, fp1);
if (c != NULL)
{
...loop here
}
line is a char array of 100 elements. Is there a similar c++ 'fgets'
command?
If not how do I change the above snippet to c++? Would like to keep the
checking for the end of file in there too.
Also it uses 'strstr' to check if a certain word is in the 'line'
array, is there a similar c++ function for this?
and similar c++ alternatives to :
strcmp
strcpy
atoi
atof
isspace
I am using djgpp under win95. I've found a libc reference in win help
file format. Is there a libc++ ref that I could download somewhere?
Would also appreciate any good c++ reference sites, I have a couple of
c++ tutorials but they don't really cover file I/O or string handling
in depth, so would appreciate any 'simple' source code, docs, tutes etc
for this sort of thing. I'm an absolute beginner so the simpler the
better.
Thanks for your time.
remove no spam from email
--
------------------------------------------------------------------------
- Raw text -