Δημοσιεύτηκε: 23 Ιουν 2011, 15:37
@migf1:
Στο tutorial σου είχες γράψει μια συνάρτηση η οποία επιστρέφει το μήκος μιας string, και εγώ για να πειραματιστώ προσπάθησα να γάψω μια πιο απλά έκδοση:
Αλλά ο compiler μου χτυπά:
Στο tutorial σου είχες γράψει μια συνάρτηση η οποία επιστρέφει το μήκος μιας string, και εγώ για να πειραματιστώ προσπάθησα να γάψω μια πιο απλά έκδοση:
- Κώδικας: Επιλογή όλων
main() {
int i;
int *p;
p = &i;
*p = 0;
char c;
int b;
c = getchar();
char mhkosgram(c) {
while(c != "\n" && c != "\0") {
i++;
if(c == " ") {
b++;
}
}
int mhkos = i - b;
printf("The lenght of the line you typed is %d charachters(Spaces and Blank Lines are not count!", mhkos);
}
}
Αλλά ο compiler μου χτυπά:
- Κώδικας: Επιλογή όλων
main.c:11:11: warning: comparison between pointer and integer
main.c:11:24: warning: comparison between pointer and integer
main.c:13:9: warning: comparison between pointer and integer
main.c:18:2: warning: incompatible implicit declaration of built-in function ‘printf’