JIGYASA
Would you like to react to this message? Create an account in a few clicks or log in to continue.
JIGYASA

An online placement forum.


You are not connected. Please login or register

Code snippet meaning

2 posters

Go down  Message [Page 1 of 1]

1Code snippet meaning Empty Code snippet meaning Wed May 12, 2010 9:51 pm

Ankit Maskara



Please explain the meaning of the following snippet.thanks in adv.

main()
{
char name[10],s[12];
scanf(" \"%[^\"]\"",s);
}

2Code snippet meaning Empty Re: Code snippet meaning Thu May 13, 2010 5:29 pm

codecrker



Uncommon thing -> use of a valid scanf converter i.e. [^\"].
[^ .....] matches the longest sequence of characters not having the characters defined within the brackets.

For ex -
char str[12];
scanf("%[^it]", str);

If the input is "Ankit" then str will have "Ank"....

Back to top  Message [Page 1 of 1]

Similar topics

-

» WA Code Snippet
» Simple C code

Permissions in this forum:
You cannot reply to topics in this forum