Can I use fgets function without problems?
my source code is:
while(fgets(linea, MAXLINEA, stdin)!=NULL)
{
if (strncmp(linea,"#",1)==0)
cont++;
strcat(larga, linea);
}
use fgets
Moderator: Board moderators
Re: use fgets
I'm not sure, but I've always used getline(cin, myString).
Greetings.
Greetings.
Runtime errors in Pascal are reported as Wrong Answers by the online judge. Be careful.
Are you dreaming right now?
http://www.dreamviews.com
Are you dreaming right now?
http://www.dreamviews.com
-
- Learning poster
- Posts: 51
- Joined: Tue Sep 04, 2007 2:12 pm
- Location: Russia, Saratov
- Contact:
Re: use fgets
Why not using just a gets()?
Re: use fgets
And what are the problems?
Re: use fgets
jedom wrote:
Can I use fgets function without problems?
my source code is:
while(fgets(linea, MAXLINEA, stdin)!=NULL)
{
if (strncmp(linea,"#",1)==0)
cont++;
strcat(larga, linea);
}
He used
if(strncmp(linea,"#",1)==0)
cont++;
Someone please tell me about the use of strncmp().
How to use it?
Can I use fgets function without problems?
my source code is:
while(fgets(linea, MAXLINEA, stdin)!=NULL)
{
if (strncmp(linea,"#",1)==0)
cont++;
strcat(larga, linea);
}
He used
if(strncmp(linea,"#",1)==0)
cont++;
Someone please tell me about the use of strncmp().
How to use it?