the example that i took from deitels book there is a code as seen below
can you explain what does it mean %[^0-9-] why do we put - in the code.Code:while (scanf("%d%[^0-9-]%lf", &account, name, &balance) != EOF) {
thanks in advance.
the example that i took from deitels book there is a code as seen below
can you explain what does it mean %[^0-9-] why do we put - in the code.Code:while (scanf("%d%[^0-9-]%lf", &account, name, &balance) != EOF) {
thanks in advance.
%[^...] means the same as %s but excludes those characters (in your case from '0' to '9' and '-').
Another thing: scanf() returns EOF only if any of the conversions can't be done and if you reach the END OF FILE in a file stream. stdin will not reach the end of file, so this is an infinite loop (except if you hit ^D on Unix terminal).
scanf() also retuns the number of successful conversions...