Dyskusja:C/strlen

Najnowszy komentarz napisał(a) 10 lat temu Adam majewski w wątku gcc

gcc edytuj

Skompilowanie tego programu pod linuksem daje :

gcc s.c
s.c: In function ‘main’:
s.c:17:5: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘size_t’
/tmp/ccVlhXzz.o: In function `main':
s.c:(.text+0x31): warning: the `gets' function is dangerous and should not be used.
s.c:(.text+0x5f): undefined reference to `getch'
collect2: ld returned 1 exit status

?

#include <stdio.h>
#include <string.h>
 
#define n 30
 
int main()
{
 
    char imie[n];
 
 
    printf("Podaj swoje imie:");
 
 
 
        gets(imie);
    printf("Twoje imie sklada sie z %d znakow\n", (int)strlen(imie));
       
    return 0;
}

Teraz działa choć zgłasza :

gcc s.c
/tmp/ccEaRQLS.o: In function `main':
s.c:(.text+0x31): warning: the `gets' function is dangerous and should not be used.


--Adam majewski (dyskusja) 21:42, 23 kwi 2013 (CEST)Odpowiedz

Powrót do strony „C/strlen”.