I am attempting to do this problem from CS50 without using the training wheels. bc somehow I can only access the regular version of VS code instead of the one that has the cs50 library. See my code below.
After I execute the code, it will prompt for both of the user inputs but it won't print them. It says segmentation fault.
Thank you.
#include <stdio.h>
#include <string.h>
typedef struct
{
char *name;
int vote;
}
candidate;
candidate get_candidate(char *prompt);
int main(void)
{
candidate president = get_candidate("Enter candidate: ");
printf("%s\n", president.name);
printf("%i\n", president.vote);
}
candidate get_candidate(char *prompt)
{
printf("%s\n", prompt);
candidate c;
printf("Enter a name:");
scanf("%s", c.name);
printf("Enter votes:");
scanf("%i", &c.vote);
return c; //go back to main
}