sscanf Question
If I had this in a array of chars:
"c:\hi.txt"
and I just wanted:
c:\hi.txt
How would I use sscanf to take out the Quotes.
I dont know the switch for quotes. Could someone help, thanks
for what possible purpose could taking out the quotes serve ?
But any way here it is
viola
"Now go away or I shall taunt you a second time"
- Monty Python and the Holy Grail
themGames Productions
Edited by - ncsu121978 on July 16, 2000 10:58:52 PM
But any way here it is
char name[30];// somewhere in here name = "C:\hi.txt" through user input or you// set itint length = strlen(name);for (int i = 0; i < length-1; i++){ name<i> = name[i+1];}name[length-2] = name[length-1];name[length-1] = '\0';
viola
"Now go away or I shall taunt you a second time"
- Monty Python and the Holy Grail
themGames Productions
Edited by - ncsu121978 on July 16, 2000 10:58:52 PM
I thought you could do it using sscanf. Well, that function you wrote only took the first letter out. It kinda looks like the one I wrote.
But using sscanf() would be much easier.
But using sscanf() would be much easier.
Yes, it can. To do so, use this:
// CHRIS
sscanf(tt, "\"%[^\"]\"", tt_new);
// CHRIS
// CHRIS [win32mfc]
Heh.. FordPrefect and I seemed to have answered at almost the same time, with (almost) the same answer.
Unfortunately, his won't work. He forgot to include the '%' sign before the "[" character.
Attention to detail... Tsk-Tsk...
// CHRIS
Edited by - win32mfc on July 16, 2000 12:09:58 AM
Unfortunately, his won't work. He forgot to include the '%' sign before the "[" character.
Attention to detail... Tsk-Tsk...
// CHRIS
Edited by - win32mfc on July 16, 2000 12:09:58 AM
// CHRIS [win32mfc]
Hi,
To get rid of the last ''"'':
Why don''t you just use something like this?
array[strlen(name)-1] = ''\0'';
Or if you have a odd name like this: "c:\data.txt"morewords
(Where the quotationmark is inside the name)
Just search for the ''\"'' in array and replace it with something appropriate.
/Mankind gave birth to God.
To get rid of the last ''"'':
Why don''t you just use something like this?
array[strlen(name)-1] = ''\0'';
Or if you have a odd name like this: "c:\data.txt"morewords
(Where the quotationmark is inside the name)
Just search for the ''\"'' in array and replace it with something appropriate.
/Mankind gave birth to God.
/Mankind gave birth to God.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement