Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!ncrlnk!wright!sdawalt From: sdawalt@wright.EDU (Shane Dawalt) Newsgroups: comp.lang.c Subject: Re: fscanf question & further puzzle Message-ID: <894@thor.wright.EDU> Date: 29 Dec 89 20:32:04 GMT References: <13805@reed.UUCP> Organization: Wright State University, Dayton OH, 45435 Lines: 32 in article <13805@reed.UUCP>, kab@reed.bitnet (Kent Black,L08,640,7754072) says: > > I dislike [fs]?scanf, and rarely use any of them, but bear with me for > NEW and IMPROVED adventures of format troubles. > Normally, these functions are used for computer generated output like lists of numbers. They are definitely not suited for human input. I am using sscanf() to tear apart plot data in SPICE output files. Works real nice. > > However, the manual says you can specify an alternate "scanset" with > brackets. This might be useful if you know the data is formatted with > strict columns (not something I would want to depend upon, but by way of > example, besides which, Mr. Smith's code is so formatted). So it seems > we could use: > ... > fscanf(stream,"%30[ a-zA-Z]s%30[ a-zA-Z]s",instr1,instr2); > printf("'%s':'%s'\n", instr1, instr2); > ... > Your problem is that you didn't catch a subtle hint in the manual. The brackets _replace_ the 's' type character. Therefore, modify your fscanf control string as shown below and it will work as expected. fscanf(stream,"%30[ a-zA-Z]%30[ a-zA-Z]",instr1,instr2); Shane email: sdawalt@cs.wright.edu 71076.511@compuserve.com