Hello,

I am very new to C but need to use it to resolve a problem.

I have a variable called "W12".

All I want to do is increment W12 to W13, W14 etc and then use it later in my code (I am using QA Load to load test an application).

I am not sure if W12 is defined as a string, an array.

As I understand it you cannot mix integers and Characters in an array, I am sure this is quite simple to do but get bogged down in C tutorials about pointers and things when I try to code it my self (no previous experaince with writing C).

Can anyone help?

Would it be possible for you to use an array called W and fill in the elements 12, 13, 14, etc. I understand what you are trying to do but I do not believe C has an "eval" type command that can assign variable names at runtime. How would you know which variable to access at any given time? You may have to rethink your methodology a bit.

Edited 6 Years Ago by jonsca: n/a

Hello,

I am very new to C but need to use it to resolve a problem.

I have a variable called "W12".

All I want to do is increment W12 to W13, W14 etc and then use it later in my code (I am using QA Load to load test an application).

I am not sure if W12 is defined as a string, an array.

As I understand it you cannot mix integers and Characters in an array, I am sure this is quite simple to do but get bogged down in C tutorials about pointers and things when I try to code it my self (no previous experaince with writing C).

Can anyone help?

It all depends on what you are really asking.

No you cannot take a variable named W12 and increment it to a variable named W13.

Yes you can take a variable that contains "W12" and increment it to "W13"

But you need to know what you have as a variable definition.

I am not sure if W12 is defined as a string, an array.

For characters they are almost identical. The only difference is
string is an array of char with the last usable char set to '\0' or NULL
array is a sequence of char containing binary values. These binary values may be all ASCII characters or may be a mix. Depends on the purpose of the array.

This article has been dead for over six months. Start a new discussion instead.