0

good morning to every one.......
How to use the %n in scanf () & printf()?
..explain in thoroughly with examples...
thanking you for giving answer

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by __avd
0

read this. I'm not going to do your homework for you.

BTW there is no such thing as "%n" in scanf. The link I give you contains all the valid characters you can put after the % sign.

Edited by Ancient Dragon: n/a

0

Read the The %n Specifier.

#include <stdio.h>
int main()
{
    char buffer[40],buffer1[40];
    buffer[0]=0; buffer1[0]=0;
    int ret;
    int count=0;
    ret = sscanf("sampletext", "%s%n%s", buffer, &count, buffer1);

    printf("\n%d",count);
    printf("\n%s\n%s",buffer,buffer1);

    ret=printf("\nTotal%n characters",&count);
    printf("\nret : %d\ncount : %d",ret,count);
 return 0;
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.