
Copy Array string to another Pointer array string in ANSI-C
Dear all,
I need your help in urgently!
My main purpose is to copy strings, which stored in array, to a
pointer string array. Initially, the strings are gotten from TXT file
and then stored in array.
Does any one help me to correct it??
Thank you very much!!
Alan
This is my C program!!
int i, idx=0;
char cmp_name[100];
char *cmp_name[100];
if ((stream_component_name = fopen("C:\\temp\\a.txt","r")) !=
NULL)
{
while (!feof(stream_component_name))
{
fgets(cmp_name, 30, stream_component_name);
if (cmp_name != NULL) {
strcpy(*(cmp_name_p + idx), &cmp_name[idx]);
idx++;
}
}
fclose(stream_component_name);
}
for (i = 0; i < 100; i++)
{
printf("%s\n",cmp_name_p);
}