C Programming - Library Functions - Discussion

Discussion Forum : Library Functions - Point Out Errors (Q.No. 3)
3.
Point out the error in the following program.
#include<stdio.h>

int main()
{
    char str[] = "IndiaBIX";
    printf("%.#s %2s", str, str);
    return 0;
}
Error: in Array declaration
Error: printf statement
Error: unspecified character in printf
No error
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
17 comments Page 1 of 2.

Neeraj kumar said:   1 decade ago
How it will print like this "%.#s %2s"?

Sms said:   1 decade ago
It prints %.#s IndiaBIX

Sundar said:   1 decade ago
Output:

In DOS 16 bit platform (Turbo C): %.#s %2s

In Linux 32 bit platfomr (GCC) : %.0#s IndiaBIX

Note: All answers given in C Programming section are based on 16-bit platform.

Sowmya said:   1 decade ago
Some one plz xlpn, whats the role of %.# here??
In floating point numbers, it will tell the number of decimals, but here in a string, what does it mean??

Vigneshwaran.L said:   1 decade ago
%.# is not operator. it is one of the symbol representation just like hex code reperesentation.like #ffff or #defe.So the linux platform (GCC )print the output is:%.0#s IndiaBix
Note:it based on machine code representation

Puneet said:   1 decade ago
The output is : %.#s %2s , string for second format %2s was also not printed why?

XYZ said:   1 decade ago
Why it is printing IndiaBIX in place of %2s?

Karthik said:   1 decade ago
Why dont print the %.#s ?

Vasantha deepika said:   1 decade ago
It prints %.#s IndiaBix . can any one explain tracing of this programme.

@brij said:   1 decade ago
char str[] = "IndiaBIX"; :- Declaration of character array.

printf("%.#s %2s", str, str); :- Its print %.#s due any symbol as u

print like anything in printf function and its print IndiaBix due %s, str here one more str which does not error in the program.
(1)


Post your comments here:

Your comments will be displayed after verification.