Jun 23, 2003 #1 xchen123 Technical User Jun 19, 2003 3 US In C code, what does the %s and %d represent? Ex: printf("Here it is %d\n",var1); printf("MSG=%s\n",buf);
In C code, what does the %s and %d represent? Ex: printf("Here it is %d\n",var1); printf("MSG=%s\n",buf);
Jun 23, 2003 #2 jbpelletier Programmer Sep 8, 2001 232 CA hi printf("Here it is %d\n",var1); //%d here mean that var1 will be print as an int. printf("MSG=%s\n",buf); //%s here mean that Buf will be print as a char array. ex) var1 = 10; printf("Here it is %d\n",var1); //will print : Here it is 10 var1 = 'A'; //will print : Here it is 65 -------------------- %c, for char ('a') %f, for float (5.55) %d, for double (100000) etc.. Upvote 0 Downvote
hi printf("Here it is %d\n",var1); //%d here mean that var1 will be print as an int. printf("MSG=%s\n",buf); //%s here mean that Buf will be print as a char array. ex) var1 = 10; printf("Here it is %d\n",var1); //will print : Here it is 10 var1 = 'A'; //will print : Here it is 65 -------------------- %c, for char ('a') %f, for float (5.55) %d, for double (100000) etc..
Jun 23, 2003 #3 dlkfjdlkfjdlfkd Programmer May 13, 2003 80 US %f for both float and double, %d is for int and %s expects a string - a null-terminated sequence of characters. Note: 'A' needn't have the integer value 65, since C doesn't require the ASCII character set. Integer character constants (e.g, 'a') have type int in C. Upvote 0 Downvote
%f for both float and double, %d is for int and %s expects a string - a null-terminated sequence of characters. Note: 'A' needn't have the integer value 65, since C doesn't require the ASCII character set. Integer character constants (e.g, 'a') have type int in C.