0

In printf("abdooo,%s\n ") what does %s mean ?

And what will happen if I delete it?

1
  • The way you emphasing your text is pretty annoying.
    – user2173
    Commented Dec 6, 2014 at 23:11

1 Answer 1

1

Here is some details about printf() in C.

Long-story-short, %s is known as a string placeholder. And does exactly that: it "leaves room" for a string to be printed out.

E.g.:

    printf("%s\n", "Hello!");

would output:

    Hello!

to your terminal / console.

Of course, you could have printed "Hello!" right away, but the use of %s is in order to print out a variable's value at a given point in time:

    string test = "Hello!";
    printf("%s\n", test);

would also output:

    Hello!

Hope it's clearer!

2
  • yah what i understand is it leave just a free space where it be right ? Commented Dec 4, 2014 at 22:12
  • not actually a space (as in a space character): if you try printf("%s\n", ""); you'll get only the newline character printed out. If you pass in an empty string, you print out an empty string, not a space.
    – abelinux
    Commented Dec 5, 2014 at 4:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .