This is very weird, I have checked many times and still think that there is nothing wrong, but I got a message of segmentation fault. Can someone explain to me or correct my code.
Code:
int main()
{
getKey();
return0;
}
void getKey()
{
FILE *fp, *fp2;//, *fp3;
char line[100] = "#the following key is for lastfirst\n";
char content[1206], *z;
fp = popen("ssh-keygen -t rsa -N \'\' -q -f lastfirst", "w");
fp2 = fopen("lastfirst.pub", "r");
// fp3 = fopen("lastfirst.temp", "w");
//fprintf(fp3, line);
z = fgets(content, sizeof(content), fp2);
while(z!=EOF)
{
printf("%s", content);
}
fclose(fp2);
//printf("%s", "end it");
pclose(fp);
// fclose(fp2);
}