Hi,
So i am trying to improve programs i write. My programs are usually for calculations due to my uni course.
At the moment my programs take in integers using scanf, but if someone puts a letter in by mistake, they crash so i want to use strings.
If i completely remove anything to do with b and c, the program can print a, but once b and c come along, it crashes. What am i doing wrong? I have no idea of the length these variables could be so i cant use arrays i dont think.Code:#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char *a, *b, *c; printf("Please input a, b and c in the form of a b c\n"); scanf("%s", a); scanf("%s", b); scanf("%s", c); printf ("%s %s %s", a, b, c); return 0; }
is there a neater way of doing this?
thanks



LinkBack URL
About LinkBacks



