请告诉我我在做什么是对还是错。如果它是正确的,那么为什么我会遇到分段错误?
#include<stdio.h>
#include<stdlib.h>
char* EncodeToBase64(char*);
int main()
{
char str[24] = {0};
char *output = NULL;
output = malloc(56*sizeof(char));
scanf("%[^\n]s",str);
output = EncodeToBase64(str);
printf("Back %s",*output);
return 0;
}
char* EncodeToBase64(char *str)
{
char buff[24];
char *output = NULL;
output = malloc(56*sizeof(char));
memset(buff,'0',sizeof(buff));
printf("EncodeToBase64 Function\n");
sprintf(buff,"echo %s | openssl enc -base64",str);
printf("%s\n",buff);
output = system(buff);
printf("Back %s",*output);
return output;
}
更正我的代码后,我又遇到了一个问题,每次我将这三个字符附加到我的字符串ô/+
中......如何获得确切的字符串?