GeeksforGeeks » C/C++ Programming Questions

Output of C program?

(2 posts)

Tags:

  1. kamal
    guest
    Posted 1 year ago #

    #include<stdio.h>
    int main(void)
    {
     printf("%.*s", 0, "geeksforgeeks");
     getchar();
     return 0;
    }
    
  2. kapil
    guest
    Posted 1 year ago #

    It doesn't print anything. See http://en.wikipedia.org/wiki/Printf#printf_format_placeholders

    If we put something other than 0 as second parameter to printf(), then we will get something printed on the screen. Like following program would print "geeks" (first 5 characters)

    #include<stdio.h>
    int main(void)
    {
     printf("%.*s", 5, "geeksforgeeks");
     getchar();
     return 0;
    }
    

Reply

You must log in to post.

RSS feed for this topic