Urban75 Home About Offline BrixtonBuzz Contact

Friend of mine is pull his hair out over this problem.

sentence[0] = 'H'
sentence[1] = 'u'
sentence[2] = 'm'
sentence[3] = 'a'
sentence[6] = 't'
sentence[7] = 'y'

etc

which is stupid and laborious but there doesn't seem to be any relationship between the original and the desired output, plus it's what the question tells you to do.

Alternatively you could define the desired output as another variable, and then iterate through 'sentence', replacing the mismatched characters. It doesn't look like that's what's being asked for, but the people who write these often do a bad job.
 
Well it has been a awfly long time since I cut any code, is this C ? Or similar ? Mayhap it's a test of a for loop or something,

// write your code here
char source [] = "Humanity and the rest of that bollix."
for (int i=0; i < strlen(source); i++)
sentence = source;


But it's a poor example, it's difficult to work out what the questioner is trying to achieve. And yes there are probably errors in the code but it has been decades so apologies to better coders than me :D, and lets face it, to achieve copying one string into another there's:

// write your code here
strcpy (sentence, "Humanity and the rest of that bollix");
 
Thanks for all the help, I have no clue but he is happy now, it's like a light went off in his head, "Ah, it was that easy" Fool is going to get no help next time
 
  • Like
Reactions: izz
Looking at the input string, I would say you can add or subtract a value to char to get output. Each word is the same length as the output string. But without looking at ASCII tables I don't know, or that could be a red herring. As izz said it's not clear what the questioner wants'
 
  • Like
Reactions: izz
Sounds to me like they want you to replace the 'incorrect' characters with the right ones, but leave the 'correct' ones (i.e. "ni", "ight", "ess", etc.) in place - basically what Mauvais said. I don't see what you're learning by doing that, though, aside from knowing that strings can be arrays.
 
Sounds to me like they want you to replace the 'incorrect' characters with the right ones, but leave the 'correct' ones (i.e. "ni", "ight", "ess", etc.) in place - basically what Mauvais said. I don't see what you're learning by doing that, though, aside from knowing that strings can be arrays.
I suppose it demonstrates that you know arrays are zero-indexed, and that spaces are entries.
 
Back
Top Bottom