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

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.

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;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.