Char variable for each for loop

Status
Not open for further replies.

zenniz

Junior Member level 3
Joined
Mar 25, 2013
Messages
29
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Singapore
Visit site
Activity points
1,497
I'm trying to write simplified program

char SPACE has no fix byte
Variable A is a random value of 1 and 0

If A = 0, SPACE = 'XX'
If A = 1, SPACE = 'Y'

I'm trying to assign one SPACE char variable for each loop int i value

Code:
char *space ????

for(int i; i = 0; i++)
{
    if(A == 1) {
        ???? = "XX"
    } else {
        ???? = "Y"
    }
}
printf("%s %s %s %s", ???????);

For example if
int 0, A = 1
int 1, A = 1
int 2, A = 0
int 3, A = 1

The end result will be "Y Y XX Y"
 
Last edited:

if SPACE is char then why assign "XX" ?!

what datatype is A? It will rarely 'equal' 1 or 0
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…