Working on an assignment for a c++ class, and I've been running into some trouble. I'm sure this is probably a very simple issue, but I'm horrible at programming, so bear with me. Here is the exercise guidelines:
You are given a file consisting of students' names in the following form: lastName, firstName midddleName. (Note that a student may not have a middle name.) Write a program that converts each name to the following form: firstName middleName lastName. Your program must read student's entire name in a variable and must consist of a function that takes as input a string, consists of a student's name, and returns the string consisting of the altered name. Use the string function find to find the inex of ,; the function length to find the length of the string; and the function substr to extract the firstName, middleName, and lastName.
The input file looks like this:
Miller, Jason Brian
Blair, Lisa Maria
Gupta, Anil Kumar
Arora, Sumit Sahil
Saleh, Rhonda Beth
I made an attempt to code at least the extraction and printing of the names, but failed miserably. My output was " Miller". I really don't understand the flaws in my logic, which I know is pathetic, but I would really appreciate any assistance that can be offered. Here's my code:
I understand the first two things, but the last one doesn't make sense to me. (not from a logic perspective, but from an execution perspective.) Thank you for your help.
So I've figured a bit more out, but it's still not working quite right. For some reason it is now skipping every other input, and I don't understand why. Here's my new code.