PostChache
November 14th, 2009, 08:10 PM
I have just started learning C and whenever I compile a program it gives me a bunch of advice on it. It runs fine though, also when my friend compiles the same program it doesn't tell him anything.
This is what it's telling me:
/home/cha-che/Documentos/Studies/Working_On/C_Primer_Plus/Exercise/Chapter_4/5.c: En la función ‘main’:
/home/cha-che/Documentos/Studies/Working_On/C_Primer_Plus/Exercise/Chapter_4/5.c:13: aviso: anchura de campo debe ser de tipo ‘int’, pero el argumento 2 es de tipo ‘size_t’
/home/cha-che/Documentos/Studies/Working_On/C_Primer_Plus/Exercise/Chapter_4/5.c:13: aviso: el formato ‘%*d’ espera el tipo ‘int’, pero el argumento 3 es de tipo ‘size_t’
/home/cha-che/Documentos/Studies/Working_On/C_Primer_Plus/Exercise/Chapter_4/5.c:13: aviso: anchura de campo debe ser de tipo ‘int’, pero el argumento 4 es de tipo ‘size_t’
/home/cha-che/Documentos/Studies/Working_On/C_Primer_Plus/Exercise/Chapter_4/5.c:13: aviso: el formato ‘%*d’ espera el tipo ‘int’, pero el argumento 5 es de tipo ‘size_t’
/home/cha-che/Documentos/Studies/Working_On/C_Primer_Plus/Exercise/Chapter_4/5.c:15: aviso: anchura de campo debe ser de tipo ‘int’, pero el argumento 2 es de tipo ‘size_t’
/home/cha-che/Documentos/Studies/Working_On/C_Primer_Plus/Exercise/Chapter_4/5.c:15: aviso: el formato ‘%*d’ espera el tipo ‘int’, pero el argumento 3 es de tipo ‘size_t’
/home/cha-che/Documentos/Studies/Working_On/C_Primer_Plus/Exercise/Chapter_4/5.c:15: aviso: anchura de campo debe ser de tipo ‘int’, pero el argumento 4 es de tipo ‘size_t’
/home/cha-che/Documentos/Studies/Working_On/C_Primer_Plus/Exercise/Chapter_4/5.c:15: aviso: el formato ‘%*d’ espera el tipo ‘int’, pero el argumento 5 es de tipo ‘size_t’
And this is my code:
#include <stdio.h>
#include <string.h>
int main(void)
{
char firstname[25], lastname[25];
printf("Please enter your first name\n");
scanf("%s", firstname);
printf("Please enter your last name\n");
scanf("%s", lastname);
printf("%s %s\n", firstname, lastname);
printf("%*d %*d\n", strlen(firstname), strlen(firstname), strlen(lastname), strlen(lastname));
printf("%s %s\n", firstname, lastname);
printf("%*d %*d\n", -strlen(firstname), strlen(firstname), -strlen(lastname), strlen(lastname));
return 0;
}
I'm really just curious on why it will compile correctly for my friend but not me. The only difference between our systems is that he uses 9.10 and I use 9.04
This is what it's telling me:
/home/cha-che/Documentos/Studies/Working_On/C_Primer_Plus/Exercise/Chapter_4/5.c: En la función ‘main’:
/home/cha-che/Documentos/Studies/Working_On/C_Primer_Plus/Exercise/Chapter_4/5.c:13: aviso: anchura de campo debe ser de tipo ‘int’, pero el argumento 2 es de tipo ‘size_t’
/home/cha-che/Documentos/Studies/Working_On/C_Primer_Plus/Exercise/Chapter_4/5.c:13: aviso: el formato ‘%*d’ espera el tipo ‘int’, pero el argumento 3 es de tipo ‘size_t’
/home/cha-che/Documentos/Studies/Working_On/C_Primer_Plus/Exercise/Chapter_4/5.c:13: aviso: anchura de campo debe ser de tipo ‘int’, pero el argumento 4 es de tipo ‘size_t’
/home/cha-che/Documentos/Studies/Working_On/C_Primer_Plus/Exercise/Chapter_4/5.c:13: aviso: el formato ‘%*d’ espera el tipo ‘int’, pero el argumento 5 es de tipo ‘size_t’
/home/cha-che/Documentos/Studies/Working_On/C_Primer_Plus/Exercise/Chapter_4/5.c:15: aviso: anchura de campo debe ser de tipo ‘int’, pero el argumento 2 es de tipo ‘size_t’
/home/cha-che/Documentos/Studies/Working_On/C_Primer_Plus/Exercise/Chapter_4/5.c:15: aviso: el formato ‘%*d’ espera el tipo ‘int’, pero el argumento 3 es de tipo ‘size_t’
/home/cha-che/Documentos/Studies/Working_On/C_Primer_Plus/Exercise/Chapter_4/5.c:15: aviso: anchura de campo debe ser de tipo ‘int’, pero el argumento 4 es de tipo ‘size_t’
/home/cha-che/Documentos/Studies/Working_On/C_Primer_Plus/Exercise/Chapter_4/5.c:15: aviso: el formato ‘%*d’ espera el tipo ‘int’, pero el argumento 5 es de tipo ‘size_t’
And this is my code:
#include <stdio.h>
#include <string.h>
int main(void)
{
char firstname[25], lastname[25];
printf("Please enter your first name\n");
scanf("%s", firstname);
printf("Please enter your last name\n");
scanf("%s", lastname);
printf("%s %s\n", firstname, lastname);
printf("%*d %*d\n", strlen(firstname), strlen(firstname), strlen(lastname), strlen(lastname));
printf("%s %s\n", firstname, lastname);
printf("%*d %*d\n", -strlen(firstname), strlen(firstname), -strlen(lastname), strlen(lastname));
return 0;
}
I'm really just curious on why it will compile correctly for my friend but not me. The only difference between our systems is that he uses 9.10 and I use 9.04