1
#include < stdio.h >

int main() {
    char *s;
    s=call();
    printf(s);
}

char* call() {
    return("hello");
}

Why these code not working. It's generating an error. How do I make it work?

6
  • What error are you getting? A compiler error? A runtime error? What is the message? Jul 8, 2011 at 11:44
  • conflicting types for all this is the error message i see. and why did the question go -1 ? Is the question wrong?
    – niko
    Jul 8, 2011 at 11:47
  • sorry guys please excuse for the question.sometimes we dont get the answer even though we know what we are doing.sorry but my problem is solved thank you all.
    – niko
    Jul 8, 2011 at 11:52
  • thanks to the one who upvoted my question.and i request if the question is too sily you can downvote i agree with you.
    – niko
    Jul 8, 2011 at 11:53
  • 1
    Probably got down-voted because people don't like guessing. The exact error message given (by the compiler?) is kind of vital, and you didn't bother to supply it.
    – T.E.D.
    Jul 8, 2011 at 11:54

1 Answer 1

2

Two things:

  • You can't put spaces inside the angle brackets when including a system header (e.g. #include <stdio.h>
  • You need a prototype for call()
1
  • In the absence of a prototype (in C89), the compiler assumes the function returns int ... and it complains when assigning that int to s, a char*.
    – pmg
    Jul 8, 2011 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.