new things for me

can someone please tell me what does these sign means??
"%d","%19","%[^\n" and stdin???
I don't know about the last two but the first shouldn't matter if you are writing in proper c++ syntax. However, it is used as arguements for scanf and printing variable values in printf
I'm guessing this is for sprintf()?
http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/

As for the last one:
http://www.cplusplus.com/reference/clibrary/cstdio/stdin/

Not sure about this one "%[^\n". Although, "\n" or '\n' are for new lines. The same as pressing Enter within a text editor.
Last edited on
That last one looks like regex.
"%[^\n]" is a format specifier for the scanf() family of functions, which instructs it to read successive characters from the input until the end of line (or end of input), storing them in successive positions of a character array. Pointer to the first element of that character array is expected as the argument to such scanf(). After reaching the \n or end of input, scanf() will store an additional null character in the array. The \n will remain in the input stream, unprocessed.

Note that just like %s, this format specifier should never be used without providing the length of the buffer (minus one, to account for the null), e.g.

1
2
3
4
5
6
7
#include<stdio.h>
int main()
{
    char s[10];
    scanf("%9[^\n]", s);
    puts(s);
}

demo: http://ideone.com/drysN
Last edited on
Topic archived. No new replies allowed.