Page 1 of 1

use fgets

Posted: Fri May 30, 2008 2:51 pm
by jedom
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);

}

Re: use fgets

Posted: Fri Jun 13, 2008 5:30 am
by andmej
I'm not sure, but I've always used getline(cin, myString).

Greetings.

Re: use fgets

Posted: Mon Jun 16, 2008 10:48 pm
by maxdiver
Why not using just a gets()?

Re: use fgets

Posted: Sat Jun 21, 2008 8:08 pm
by Megov
And what are the problems?

Re: use fgets

Posted: Mon Oct 06, 2008 3:02 pm
by lnr
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?