Made some of the recommended changes...
also figured out a loop to replace random characters!
Code:
#include <stdio.h>
void get_colors(char *pointer);
int main(void){
int n = 6, j, i;
char scanned[6][7];
char color[12][7];
char *pcolor;
char *pscanned;
/* Declare pointers to their arrays */
pcolor = &color[0][0];
pscanned = &scanned[0][0];
get_colors(pscanned);
for(j = 0; j<6; j++){
for(i = 0; i<7; i++){
printf("%c", scanned[j][i]);
} printf("\n");
}
getchar();
return 0;
}
void get_colors(char *pointer){
int i, j, k;
char x, y;
int check;
x = '\0';
y = ' ';
printf("Please enter 6 resistor colors: \n");
scanf("%s %s %s %s %s %s", pointer, (pointer+7), (pointer+14), (pointer+21), (pointer+28), (pointer+35)) ;
/* Replace characters after the first \0 with empty spaces */
for(i = 0; i < 42; i++){
if(*(pointer+i) == x) {
for(j = i%7; j<7; j++){
k = 0;
*(pointer+i) = y;
i++;
}
}
}
}
thoughts / opinions?
i got rid of all the weird errors