You can use strtok (string. H). Please be careful, this function will modify your source string (you may copy the string before) Example for strtok: char* word; // First word: word = strtok(str, " "); // space as the delimiter strncpy(name1, word, sizeof(name1) - 1); name1sizeof(name1) - 1 = 0; // end of word, in case the word size is > sizeof(name1) // Second word word = strtok (NULL, " "); strncpy(name2, word, sizeof(name2) - 1); name2sizeof(name2) - 1 = 0 Also, I think you should chec.
You can use strtok (string. H). Please be careful, this function will modify your source string (you may copy the string before).
Example for strtok: char* word; // First word: word = strtok(str, " "); // space as the delimiter strncpy(name1, word, sizeof(name1) - 1); name1sizeof(name1) - 1 = 0; // end of word, in case the word size is > sizeof(name1) // Second word word = strtok (NULL, " "); strncpy(name2, word, sizeof(name2) - 1); name2sizeof(name2) - 1 = 0; Also, I think you should chec.
If you are going from standard input, there is no way of stopping this, the user can enter what they like. It would be preferable to read in all the input first then check then result.
– Jono May 12 at 11:35 Depends, basically you would need to examine the input to see what you have got. You could have all sorts of characters in that string, including numbers, special characters, etc.I would not recommend using sscanf on the input if that is what you mean. – Sasquiha May 12 at 12:51 So far I used fgets , got the whole line, and used isspace to determine if there is more than 1 whitespace ... is that ok?
– Jono May 12 at 13:00 have a look at strtok() – Sasquiha May 12 at 13:35.
You can use fgets to read all the line, and then parse the results. For example: char name256; for (int I = 0; I Now you need to parse this string, if user enter wrong input (as "aaa" or "aaa bbb ccc") return error, else ("aaa bbb"), split the string and use "aaa" as name1 and "bbb" as name2.
Fgets is to read from file not keyboard. – Amir May 12 at 11:52 what if we are provided with test cases file like , test00. In test00.out.In this case would fgets be suitable?
– Jono May 12 at 11:54 Yes. Also, pmg is right, you can use the console as the file. See example in wiki: en.wikipedia.
Org/wiki/Fgets – Amir May 12 at 12:01 fgets(line, sizeof line, stdin) reads from the keyboard .. well, from stdin and stdin is, very often, the keyboard. – pmg May 12 at 12:06.
On Windows it works completely fine. It should encrypt given text. What am I doing wrong?
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.