I can't figure out how to save a user input character string.
I want to ask the user for two separate string variables (a word) and store them for later use as reference
and query
variables. I thought of using the scanf
to obtain the user input and %s
for storing the variables.
I either get segmentation fault or wrong output depending on how I modify the code. What am I doing wrong?
#include <stdio.h>
#include <errno.h>
#include <string.h>
int main(void)
{
char *reference, *query;
printf("\n Enter reference genome file name: ");
scanf("%s", reference);
printf("\n Enter sequence query file name: ");
scanf("%s", query);
printf("\n\n Reference file used was: %s\n", reference);
printf("Query sequence file used was: %s\n", query);
return 0;
}