Exforsys
+ Reply to Thread
Results 1 to 2 of 2

Program Fails

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("%s\n", strcmp("Test","test")); } But the above program ...

  1. #1
    Adrian is offline Senior Member Array
    Join Date
    Apr 2006
    Answers
    124

    Question Program Fails

    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.


  2. #2
    sammy is offline Senior Member Array
    Join Date
    Apr 2006
    Answers
    144
    The program fails because strcomp() function returns a integer. But you have used qualifier in printf function as &#37;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.


Latest Article

Network Security Risk Assessment and Measurement

Read More...