08/02/23 23:48:55
これがたまたまうまく動いたりしますが、実際は間違っているから困っているんです
#include <stdio.h>
#include <string.h>
typedef struct { char *start ; char *end; } bin;
void f(bin *x) {
delete x->start;
x->start = new char [3];
strcpy(x->start,"aa"); }
main() {
char *ch = new char [2];
strcpy(ch,"a");
bin x;
x.start=ch; x.end=ch+strlen(ch);
f(&x);
printf("%s",ch);
}