Skip to content

Instantly share code, notes, and snippets.

@Pavelovich
Created June 26, 2014 16:28
Show Gist options
  • Save Pavelovich/07d4a1cf6fface3fe583 to your computer and use it in GitHub Desktop.
Save Pavelovich/07d4a1cf6fface3fe583 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int askInt(char *question[200])
{
int number;
printf(question);
scanf("%d", &number);
printf("The number is %d \n", number);
return number;
}
char askChar(char *question[200])
{
char text[200];
printf(question);
scanf("%s", text);
printf("The string is: %s \n", text);
return text;
}
double askDouble(char *question[200])
{
double number;
printf(question);
scanf("%lf", number);
printf("The number is %lf \n", number);
return number;
}
int main(int argc, char *argv[]) {
askInt("Enter a number: ");
askChar("Enter a string: ");
askDouble("Enter another number: "); // Segmentation fault after the input for this
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment