Null characters added to array

Using straight C & attempting to compile with VS2K5 I am ending up with the first four elements of arrays being null. I have tried different projects with different config settings. I understand there are many different ways to do what I'm trying to do, I do not understand why I am getting four null chars at the beginning of my arrays though.

#include <stdio.h>

void main(void)

{

char CameraOut[200];

int i=0,k=0;

char *CameraOutTester = "10 -90 10 +90 XXX";

while(*CameraOutTester != 'X')

{

CameraOutIdea = *CameraOutTester;

CameraOutTester++;

i++;

}

k = i;

for (i=0; i < k; i++)

{

printf("%c\n", CameraOutIdea);

}

printf("stop\n");

}



Answer this question

Null characters added to array

  • NikosG

    I tried it on gnu compiler and no issues at all. It works perfectly. Probably you should try to memset/memcpy the CameraOout Array b4 using. i.e. memset(CameraOut,'0',200); That may work
  • Null characters added to array