Quite a few little things I'd change, along with some bigger ones.
Code:
#include <stdio.h>
char A[] = "GGGGG GG GGGG GG GGGGG G G G ";
char B[] = "10101100010101010101010101010110";
void ABC()
{
size_t i;
for ( i = 0; i < sizeof A / sizeof *A - 1; ++i )
{
if ( A[i] == ' ' )
{
B[i] = 'P';
}
}
}
int main(void)
{
printf("[%s]\n", A);
printf("[%s]\n", B);
puts("change:");
ABC();
printf("[%s]\n", A);
printf("[%s]\n", B);
return 0;
}
/* my output
[GGGGG GG GGGG GG GGGGG G G G ]
[10101100010101010101010101010110]
change:
[GGGGG GG GGGG GG GGGGG G G G ]
[10101P00P1010PP10PPP01010P0P0P1P]
*/
[edit]Perhaps I'd even use this for the loop condition instead.
Code:
int i;
for ( i = 0; A[i] != '\0'; ++i )
[edit=again, can't I do things right the first time?]
Is your array a char array? And is it a C-string? Such things make a difference in some of the choices I've made above.