[Solved] C for loop not working


I tried to run that and my outputs for r1 and r2 are

qwdaweqwe

asdas–sd (two spaces)

and basically it is what the code should be doing.

But if I get your intention right, you want to work with those empty strings. Then you should be feeding your function with different numbers, because array indexing works from 0 to n-1, meaning that if you want to use the second empty string, use index 2. I tried that, but there is problem with the declaration. You can try this

char str[5][10] = { "asdasdasd", "         ", "         ", "qweqweqwe", "asdasdasd" };

or some fine malloc for those two empty strings. Code above works.

0

solved C for loop not working