Start New Discussion within our Software Development Community

So the "substr" command is used for extracting certain characters, i have a problem in which if the character is a space, the previous value is used for filling the variable
The code:

#include "stdafx.h"

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
    string line="Introductory Chemistry";
    char character;

    for(int i=0;i<line.length();i++)




    return 0;

the output should be each character printed out vertically, but where there is supposed to be a space, it is the previous character. The last bit proves this as 12 is the character that contains the space, but it returns the value "y". Further information is that no arrays can be used.

This question has already been answered. Start a new discussion instead.