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"
#include<cmath>
#include<string>
#include<iostream>
#include<sstream>

using namespace std;

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

    for(int i=0;i<line.length();i++)
    {
        stringstream(line.substr(i,1))>>character;

        cout<<character<<endl;
    }

    cout<<endl;

    stringstream(line.substr(12,1))>>character;
    cout<<character;

    system("Pause");
    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.

Nvm i fixed the problem, all i did was remove the string stream crap

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.