Hello,
Programming troubles.
So here is the deal. In the program below I'm supposed to make some functions which I did and use my new found knowledge of functions to output from a file a input which is like the following.
2
Sally Robertson
456 Cross Ave East
Somewhere Else, New Mexicio 91991
Where the number 2 is a print selection. There are three total choice numbers 1,2,3. The choices work themselves the trouble is when I go to loop in main. I want to continue this process for how ever main addresses and lines I have.
This is a copy of my input I'm just using two groups I will have more in the future.
1
Sam Alexander Smith
1234 S. Main Street
Anywhere, U.S.A. 99999-0000
2
Sally Robertson
456 Cross Ave East
Somewhere Else, New Mexicio 91991
This is my code;
#include<iomanip>
#include<iostream>
#include <string>
#include <fstream>
using namespace std;
}
OK, so let me tell you about the problem. It reads the file once correctly, stops, then after I hit any key the loop outputs the next address. Which is not correct it is a repetition of the first except the print selection is properly chosen which makes the output different but the strings three lines of address stay the same. For instance look at the input file above it reads the number 2 but outputs the appropriate formatting with the same address as the first.
I hope that I have explained myself sufficiently if not just ask me and I can try and rephrase what I was explaining. And yes I know that void main() is not correct it should be int main() or something but it compiles and its what my teacher uses so lets just overlook this ha.
Thanks
Never mind I figured the loop question I'm stuck though on formatting this box
It is supposed to trim it if it is to long and all that it does is add an extra space or if it is over the limit it doesn't trim it. But I have used setw and substring so Why would it do this ?
Here is the function
There are three of these one for each type of string. But they are all the same and all producing the same result. The line with the else if(str1.length()>=LIMIT) is the problem and the code following that else if.