C examples for Language Basics:printf
Use the %u or %lu specifiers if your implementation does not recognize the %zd specifier in printf
#include <stdio.h> #include <string.h> /* provides strlen() prototype */ #define PRAISE "this is a test test test test." int main(void) { char name[40]; //from ww w .j av a2 s . c o m printf("What's your name? "); scanf("%s", name); printf("Hello, %s. %s\n", name, PRAISE); printf("Your name of %zd letters occupies %zd memory cells.\n", strlen(name), sizeof name); printf("It has %zd letters ", strlen(PRAISE)); printf("and occupies %zd memory cells.\n", sizeof PRAISE); return 0; }