petit soucis dans le main..
Bonsoir , j'ai écrit un programme qui m'affiche la longueur de chaque ligne rencontrée en entrée , pour ce ci j'ai 2 fichiers , une fonction lireligne qui affiche la longueur d'une ligne , et un programme main pour l'éxécuter , voici les codes :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
/* fonction */
#include <stdio.h>
int lireligne(char s[], int lim)
{
int c, i;
for ( i=0; i < lim - 1 && (c=getchar()) != EOF && c!='\n'; ++i)
s[i] = c;
if ( c == '\n' )
{
s[i] = c;
++i;
}
s[i] = '\0';
return i;
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
int lireligne(char ligne[], int taille);
int main(void)
{
int l = 0;
int c;
while ((c=getchar() !=EOF && lireligne > 0 )
{
if ( c == '\n' )
++l;
else
l = 0;
}
printf("%d\n", l);
} |
message d'erreur pour la compilation :
Citation:
main.c : warning ordered comparaison of pointer with integer zero , control reaches end of non void function .
Est ce que par hasard çà serait parce que j'ai oublié le return 0 ?
merci
Re: petit soucis dans le main..
Citation:
Envoyé par Bibouda
Est ce que par hasard çà serait parce que j'ai oublié le return 0 ?
Oui
Re: petit soucis dans le main..
Citation:
Envoyé par Bibouda
voici les codes :
Merci de ne pas recopier le code à la main, mais de le copier/coller
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
Compiling: main.c
main.c:11: warning: no previous prototype for 'lireligne'
main.c: In function `main_':
main.c:30: warning: ordered comparison of pointer with integer zero
main.c:31: error: syntax error before '{' token
main.c:27: warning: unused variable `l'
main.c: At top level:
main.c:37: error: syntax error before string constant
main.c:37: warning: type defaults to `int' in declaration of `printf'
main.c:37: warning: function declaration isn't a prototype
main.c:37: error: conflicting types for 'printf'
main.c:37: note: a parameter list with an ellipsis can't match an empty parameter name list declaration
main.c:37: error: conflicting types for 'printf'
main.c:37: note: a parameter list with an ellipsis can't match an empty parameter name list declaration
main.c:37: warning: data definition has no type or storage class
Process terminated with status 1 (0 minutes, 0 seconds) |
On pert du temps là...
Pourquoi du code aussi compliqué ?
[EDIT]
Oups, j'ai besoin de vacances là... Que des bétises aujourd'hui... J'avais compris "compter les lignes"... Désolé.