Is it possible to create a series like this

char j;
int ,k;
for(int i=0;i<10;i++){
k=ji;
}

I get an error but want to create something like
j0
j1
j2
and so on...

How do i do that ?

Member Avatar for onaclov2000

first off...you're trying to store ji as a integer, and it's not an integer, you would most likely want to store it as a string or char array.
so what you would want to do is write it as string k, then say

k = "j" + i;

I believe that would be the "syntax" the + might or might not be right, I don't have a compiler in front of me.

Also in that case you don't need j as a char, you can just use the character j for real....if that makes sense....

so finally the code should look like this I think

string k;
for(int i=0;i<10;i++){
k="j" + i;
}

you might want to add a new line, or something like that to the end so you get a "string" that has all the items on a new line each.

Another option is to write a string array and store the j# in each item in the array.

Good luck,
Let us know how it turns out.

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.