1 votes 1 votes #include<stdio.h> int main() { char *s = "Geeks Quiz"; int n = 7; printf("%.*s", n, s); return 0; } Programming in C programming-in-c pointers array + – Sandip Shaw asked Feb 25, 2016 Sandip Shaw 2.5k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 4 votes 4 votes OUTPUT: Geeks Q EXPLANATION char *s = "Geeks Quiz"; Store the string "Geeks Quiz" in memory and stores the base address in pointer s. printf("%.*s",n,s); .number: Its a precision which specifies the minimum number of character/digits to be printed. .*: The precision is not specified in the format string, but as an additional integer value argument preceding the argument that has to be formatted. Therefore, the above line will print 7 characters (as specified by n) of string s. SOURCE: Tutorials Point (Click on link to read more about formatting in printf) Ouput after executing the above code on Ideoneis here. prateekdwv answered Feb 26, 2016 • selected Mar 5, 2016 by abhilashpanicker29 prateekdwv comment Share Follow See all 0 reply Please log in or register to add a comment.