Predict the output!

Q. I have an error free C code, am writing for you. This code searches for the string “C+Trivia” in Google. Surprised, how it can be?

#include "stdio.h"
#include "stdlib.h"
int main()
char* str;
printf("C + Trivia",str);
return 0;

Read more about this program here.

Did you run the code on your system? Yes???
roflolzzz :):):):):)!!!
understood the program or i need to explain anything?
Had you thought of Google search to be so easy in C??
Thanks Linux For You!


4 comments on “Predict the output!

  1. @hardy:
    it is not doing anything like Search in Google!
    the http line is valid, since http: becomes a label and
    // is a valid C comment.
    Every other thing in a program is well understood.

    • getting the error while compiling your piece of code …. help me maverick 😛

      [root@localhost test]# gcc code.c
      code.c: In function ‘main’:
      code.c:8: error: expected expression before ‘char’
      code.c:9: error: ‘str’ undeclared (first use in this function)
      code.c:9: error: (Each undeclared identifier is reported only once
      code.c:9: error: for each function it appears in.)

      • Did you try fixing it?
        errors say they don’t find any declaration of “str” once the label is set.
        write char* str; before the label to get rid of it.

        The intent was not to get it work correctly but just to know the trivial thing in the code.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s