I want a for loop to loop thru each line of a text file.
I want this in C programming not in C++. Because the libs objs i am using in my project are not allowing me to use getline function in C++. evrytime I use that function, it throws a linking error lnk2005 already defined in one of the obj file which i am using in my project.
First it should take the first line then loop thru all other line. Then take the 2nd line and loop thru all other lines below that and so.
So I was thinking of having two for loops one inside the other.
like
1 2 3 4 5 6 7 8
for(loop thru the lines of text file)
{
get the firstline. and do your work on that
for(loop thru the lines below that line)
{
get the 2nd/3rd/etc line. do your work on that
}
}
I am a beginner in programming. So please help me.
Why would you use a strlen function, which requires a terminating nul character to determine the length of a string to decide where to place a terminating nul character to end a string? Why are you using C file functions? Why are you using a character array instead of a string?
Thanks for your reply. As I mentioned in my first post, I cannot use getline function in my program since it conflicts with one of the obj file which i am suing in my program and is a mandatory obj file for my tool to run in the application i am using.
getline throws a linking error lnk2005 which says getline is already defined in xxx.obj file.
It's often frowned upon, except in VERY simple projects,
to use an entire namespace (especially for something so large)...
New people don't often learn this, because the docs teaching them are often usingnamespace std;