This is a discussion on Program Fails within the C and C++ forums, part of the Programming Talk category; I have written the below C program #include <string.h> #include <stdio.h> main() { printf("%...
|
|||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I have written the below C program
#include <string.h> #include <stdio.h> main() { printf("%s\n", strcmp("Test","test")); } But the above program gives error. Kindly help me to understand why the above program fails. |
|
|||
|
The program fails because strcomp() function returns a integer. But you have used qualifier in printf function as %s which is for strings. Since there is discrepancy you have got error. So use the qualifiers with printf and scanf functions for carrying out output and input operations correctly with the input and output data type given.
|
![]() |
| Thread Tools | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) | Steve Summit | Tech FAQ | 0 | 06-15-2004 07:00 AM |
| comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) | Steve Summit | Tech FAQ | 0 | 06-01-2004 07:01 AM |
| comp.lang.c Answers to Frequently Asked Questions (FAQ List) | Steve Summit | Tech FAQ | 0 | 06-01-2004 07:00 AM |
| comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) | Steve Summit | Tech FAQ | 0 | 05-15-2004 07:00 AM |
| Apple II Csa2 FAQs: Telecom Hardware & Transfers, Part 20/25 | rubywand@swbell.net | Tech FAQ | 0 | 04-04-2004 08:29 AM |