here in this program the void function should attach the numbers that entered by user with (e) and number of index..
void generateNew(string NewID[], int size)
{
for(int x=0;x<size;x++)// for loop to represent the new numbers
{
cout << "The New ID of item " << (x+1) <<
" is e" << x << NewID[x] << endl;
}
}
BUT, the screen display letters instead of the stored numbers !!
how to solve it?
, BTW there is no errors it compiles successfully
String also can be use to store number.
i been trying to do a program like this, but no problem been found
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <iostream>
usingnamespace std;
int main()
{
string NewID[3];
int size=3;
for(int x=0;x<size;x++)
cin>>NewID[x];
for(int x=0;x<size;x++)// for loop to represent the new numbers
cout << "The New ID of item " << (x+1) <<" is e" << x << NewID[x] << endl;
system ("pause");
return 0;
}
12345
23456
34567
The New ID of item 1 is e012345
The New ID of item 2 is e123456
The New ID of item 3 is e234567
Press any key to continue . . .
If u still having the problem, i guess the problem come from the part where u let the user enter and store the ID... try have a look at there..
yeah , it works with me either because it's all in one function ,
but when the part which attach the number with (e)... in other function it doesn't work with string
dunno why! :/ it works only with int.
void generateNew(string NewID[], int size)
{
for(int x=0;x<size;x++)// for loop to represent the new numbers
{
cout << "The New ID of item " << (x+1) <<
" is e" << x << NewID[x] << endl;
}