[ Date Index ][
Thread Index ]
[ <= Previous by date /
thread ]
[ Next by date /
thread => ]
On Tuesday 09 April 2002 11:26 pm, Steve Marvell wrote:
On Tue, Apr 09, 2002 at 10:52:00PM +0100, Neil Williams wrote:How do I parse this string: ITEMNAME="245"using sscanf.
Couldn't get it to remove the final ", I always ended up with 245" - not much use to an integer variable!! I now use strtok(): char string[]="ITEMNAME=\"256\""; char *buffer; int output=0; char *buff2; buffer=strtok(string,"\"\""); buffer=strtok(NULL,"\"\""); buff2=strtok(string,"="); output=atoi(buffer); cout << "Attribute name is " << buff2 << endl << "attribute value is " << output << endl; Found that in the KDevelop manual. Unexpectedly useful! -- Neil Williams ============= http://www.codehelp.co.uk neil@xxxxxxxxxxxxxx linux@xxxxxxxxxxxxxx neil@xxxxxxxxxxxx -- The Mailing List for the Devon & Cornwall LUG Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the message body to unsubscribe.