trying to copy pointer in array.
lets say *pointer has the value "COMPUTER". and i want to store in array[o];
note: i want to use strcat to do this and i do not want to do some thing like "array[0]"

char test[10];
char *point;         //has the value "COMPUTER"

for(int i = 0; i < 10; i++)
  test[i] = '\0';

strcat(test, point);      //store value at end of test array. so test[0] is computer

for(int i = 0; i < 10; i++)

not sure why this dont work;

print that tab in this way:


or use std::cout

1st of all there is "Multiple declaration of "i" " instead of declaring i twice in for loop, declare it once like

int i; 

between the lines 1 and 2.
=> test[0] cant be computer, "Computer" is a string and test[0] is a character type.
=> there is no use of second for loop. and even if you are using, in printf statement write,


because, as i mentioned in 1st point, test[0], test[1],........test[10] are characters.. only "test" is string.

you can use the following code:

void main()
  char test[10];  int i;
char *point="COMPUTER";
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.