vendredi 27 février 2015

What is the difference between gets() and scanf()


#include <stdio.h>

int main()
{
char text[100];
int length = 0;

gets(text);

while (text[length] != '\0')
length++;

printf("%d",length);
}


I was trying to count the letters in an string using the above program. it worked. But, when i tried the same program with scanf() instead of gets(), it didn`t work. pls help me...


Aucun commentaire:

Enregistrer un commentaire