Thread: What’s going on here? I think variable problems.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2019
    Posts
    50

    What’s going on here? Int variable problems.

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    #include <string.h>
    #include <math.h>
    
    int main()
    {
    	int age;
    	
    	puts("How old was Methusalah?");
    	scanf(&age);
    	printf("Okay, so...Methusalah was %d years old.", age);
    	
    	
    	return 0;
    Just 2 days ago I was writing MUCH more complex programs. Now I can’t get a basic int variable to store input from the user. Wtf have I done wrong? It keeps saying Methuselah was 0 years old, no matter the input value.
    Last edited by Ctylersills; 03-28-2019 at 12:11 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. unused variable causes lots of problems
    By Isnalla in forum C Programming
    Replies: 1
    Last Post: 02-25-2012, 10:40 AM
  2. Replies: 4
    Last Post: 11-30-2005, 02:05 PM
  3. problems with passing ostream variable
    By paperbox005 in forum C++ Programming
    Replies: 2
    Last Post: 07-31-2004, 12:31 AM
  4. Variable Type Problems
    By Gnoober in forum C++ Programming
    Replies: 8
    Last Post: 10-14-2002, 04:28 PM
  5. Having problems incrementing variable names
    By Legolas in forum C++ Programming
    Replies: 4
    Last Post: 11-11-2001, 10:14 PM

Tags for this Thread