Question

I am trying to figure out how I can make my program read what the user is typing in, such as a numeric value in this case but I'm having trouble. Here is what I put so far. The first part of the code is just a fake name and email address that just outputs my credentials (so that shouldn't matter).

#include <stdio.h>

int main(void)

{
     printf("John Smith\n");
     printf("abc@abc.com\n");

     /* User must enter values in feet */
     int d;
     printf("Enter length for side a: \n");
     scanf(" %d");

     return 0;
}
Was it helpful?

Solution

You forgot to put your variable into the scanf:

scanf(" %d", &d);
printf("You entered %d\n", d);

OTHER TIPS

To read a value from scanf you must give it the address of the variable using (&)

Like so:

scanf(" %d",&d);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top