Hi this program accepts the string from the input. I cannot understand the highlighted format specifier. Please help me understand.

#include "stdafx.h"

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
	char str[15];
	scanf("[B]%[^\n][/B]",str);

	str[0]=toupper(str[0]);
	
	str[15]='\0';
	printf("%s",str);

	putchar(123);

	getch();
	return 0;
}

It's a scanset. scanf() will look for characters between the brackets. A leading ^ acts as an exclusion modifier, so %[^\n] will look for anything that's not a newline and stop reading when it encounters a newline.

And don't be like me and keep trying to add an s into that format specifier! ;)

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.