가능한 중복 : 나는 C에서 다른 문자에 문자열의 문자를 변경하려고 해요 그래서
Problem with processing individual strings stored in an array of pointers to multiple strings in CC 프로그래밍 - 문자열 배열 요소의 변경 문자
확인 문제는 각 문자열이 1D 배열의 요소이므로 문자열 자체가 문자 배열이기 때문에 본질적으로 모두 함께 2D 배열입니다. 어쨌든이 작업을 수행하는 코드를 만드는 데 문제가 있습니다. 이것을 할 수 있습니까? 어떤 도움을 주셔서 감사합니다.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int i, size;
char **a;
a=(char**)malloc(sizeof(char*));
printf("Enter the size of the array:");
scanf("%d", &size);
for(i=0;i<size;i++){
a[i]=(char*)malloc(sizeof(char)*8);
}
a[3]="Read";
while(*(a[3])!='\0'){
if(*(a[3]) == 'e'){
*(a[3]) = 'r';
}
}
printf("%s\n", a[3]);
system("pause");
return 0;
}
문제가 정확히 무엇을 걸을를 사용하는 것입니다? 너는 말하지 않았다. 오류가 있습니까? –