Even characters

  • 12
  • Locked
Read 2 file names from the console. Output to the second file all characters from the first file with an even ordinal number (ordinal numbers start with 1). Example first file: text in file Output in the second file: eti ie Close the IO streams.
You can't complete this task, because you're not signed in.
Comments (3)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Justin Smith
Level 39 , Greenfield, USA, United States
12 October 2021, 16:55
It would be nice if there was a sub-comments section for each task called "Discuss your solution". My solution is nice and clean and doesn't involve creating a list like the official solution does. The whole thing is done in the file.ready while loop in 5 lines of code (not counting brackets). But we're not supposed to post solutions here. I'd like a place where we can share and compare how we did it. I think it would be an invaluable learning tool for a lot of people.
Patrick Moreland
Level 27 , Kirkland, United States
13 April 2020, 01:13
I flailed around with this one way too long because I didn't understand what ordinal meant. I was thinking it meant the first digit of the ASCII value of the number was 1, such as 1, 10-19 and 100-127. I now see that ordinal means the index position of the order in which character is read starting with 1, as in "first". What a waste of time.
Level 25
26 April 2020, 03:17
Yes, thank you for explaining. You saved me some time.