convert random string data to int value then into ascII

I need to take a line from a .txt file like 63g-8h6i 24-\pdfh r random sentence and somehow take 63 from the 1st part and make it the ascII character for 63 which is ? then make that the setfill, then take the 24 from the second part and use it to set width the take the r and use it to right justify then fill in the string random sentence so it would look like: ?????????random sentence.

I just need to know how to take in 63g-8h6i and somehow get just 63 an then convert that to the ascII value... I feel like the professor tossed us in the deep end on this one.

we mostly only learned cin, cout, cin.getline, and things like that. so please don't give me some complex std:: type thing because I'm not there yet. It doesn't have to be the way you would do it because I'm sure that's better, just the way a noob like myself might do it with my limited knowledge and skills.
Last edited on
something like this:
1
2
3
4
5
6
    ifstream fin("input.txt");
    int a;

    fin >> a;              // get the first integer
    fin.ignore(100, ' ');  // ignore everything up to and including the next space.
    char ch = a;


That reads an integer from the file fin into the variable a and puts the corresponding ASCII character into ch.

You can repeat lines 4 and 5 with an int, then a char to get the next number and then the 'r'.

After that, a getline to read the sentence into a string. And finally, output the string using the appropriate width, fill character and justification.
Topic archived. No new replies allowed.