I Want To Take Some Integers To An Array[1000]. To Do This Im Using A Loop.But The Program Says It Must End Taking The Values When The User Enters A Character. I Don't Know How To Do IT. It Keeps Looping When I Enter /a /character.
The Other Thing Is I'm Passing These Numbers To A Function Which Will Remove All The Duplicate Numbers And Display Only Non Duplicated Numbers. Is This Right?
#include <sstream> // for stringstream
#include <string>
int main()
{
int num[1000]={0},number=0;
int temp=0,x=0;
string s; // Note
for(int j=0;x!=99;j++)
{
if(number<1000)
{
cout<<"Put: ";
cin>>s; // Note: now enter a string
if(s == "a") // Check if it's an 'a'
break; // then break
else
{
stringstream ss(s); // Use the stringstream
ss>>number; // to convert s to int
num[j]=number;
number=0;
temp=j;
}
}
else
{
x=99;
break;
}
}
Thank you For Your Reply. Do You Know How To Modify This Code To Stop Looping For Any Alphabetical Character. I Didn't Know About SStream. I Will Start Researching About That. Thanks Again.