if you're worried about whitespace, convert all whitespaces to a character you're sure won't be used anywhere else, say underscore (you can change it to whatever) and then change it back afterwards. here are some example functions to get you started:
Code:
#include <iostream>
using namespace std;
void removeWhitespace(char[] input, int len) {
for (int i = 0; i < len; i++) {
if (input[i] == " ") {
input[i] = "_"; //this is line you change to alter the character--change the underscore to whatever you want
}
}
}
void putWhitespaceBack(char[] input, int len) {
for (int i = 0; i < len; i++) {
if (input[i] == "_") { //if you change the underscore, you'll have to change it here also
input[i] = " ";
}
}
}
int main() {
char mystr[100] = "Hello, my name is Bob";
cout << mystr << endl;
removeWhitespace(mystr, 100);
cout << mystr << endl;
putWhitespaceBack(mystr, 100);
cout << mystr << endl;
return 0;
}
you don't have to return input[] from those functions because when you pass an array it is like a pointer so THE TWO FUNCTIONS ARE OPERATING DIRECTLY ON THE ARRAY. that can be good and bad.
this is in c++. it looks like you may be using C because of your use of sscanf() but i loooked up C output and tried to use it (puts), got that working but apparently there are other differences like with for-loops that i don't know about. but this should get you pointed in the right direction, at least.