Sscanf and strings?

Your character pointers are unitialized, and point to a random segment of memory. You must allocate a buffer for sscanf() to write to, and it must be big enough. (You're lucky that didn't segfault.) That second part is the hard part -- scanf() might not be the right tool for the job here.

Ah, OK, that makes sense. The strings are of a prescribed, fixed length. What is the best way to go about allocating space for the pointers?

– James Harrison Jul 1 '09 at 0:39 Changed my definition to char issued30,bid10; and the matcher to %^, instead of %s. Not perfect, but does the job and works. – James Harrison Jul 1 '09 at 1:06 Yet again a classic scanf problem.

IMHO scanf is the devil's function (along with realloc...) and should NOT be used unless there really is no alternative. – AAT Sep 11 '09 at 10:52 scanf() can be useful, when used properly. I do not understand your comments on realloc().

– Thanatos Sep 12 '09 at 21:17.

%s matches non-whitespace characters. What you probably want is %^,255 which will match every character other than , instead of %s. The 255, which is optional, specifies the field width that you're expecting for that field.

Good advice, but not immediately the source of the trouble. – Jonathan Leffler Jul 1 '09 at 0:49 Yes, although it seems like the sscanf would barf on the date, and wouldn't match anything beyond that since its expecting a , instead of a space. – Peter Kovacs Jul 1 '09 at 0:58.

I agree with Thanatos. As a first start you need to allocate memory for issued and bid, you might do: char issued1024; char bid1024.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions