String

So I am making a program that lets you enter in a random string of 1's and 0's and it will output the exact opposite of that string.

for example:
101001011 would return
010110100

Im trying to learn about strings and i need help to start programming this.

Thanks :)
Ask for a string. Create another string of the same size. Iterate through the first one, and for every '1' write a '0' at the same position in the second one (same for '0' s)
also dont read it into a string, read it into a char array[]
@ascii.... uhhhhhh I disagree.
....
Don't read it into a char array, read it into a string.
You don't necessarily need to create a second one either, you can just change the original if you no longer need it.
Last edited on
Topic archived. No new replies allowed.