C2065 Undeclared Identifier Error

This is a discussion on C2065 Undeclared Identifier Error within the C Programming forums, part of the General Programming Boards category; I can't seem to figure out why I am get the error 2065: Undeclared identifier for 'PowerValue' and C2143:Syntax Error ...

  1. #1
    Registered User
    Join Date
    May 2013
    Posts
    23

    C2065 Undeclared Identifier Error

    I can't seem to figure out why I am get the error 2065: Undeclared identifier for 'PowerValue' and C2143:Syntax Error : Missing ';' before 'type' on line 13.
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    
    void main ()
    {
    	int NumbertoMultiply;
    	int X; /*Answer after the number get multiplies a number by a factor 2 to the power n*/
    	printf("Please enter the number to multiply: ");
    	scanf_s("%d",NumbertoMultiply);
    
    
    	int PowerValue;
    	printf("Please enter the number for the power: ");
    	scanf_s("%d",PowerValue);
    
    
    	X = (NumbertoMultiply << PowerValue);
    
    
    	printf("Here is the value of X which was multiplied by your given number by a factor 2 to the power: %d",X);
    	
    
    
    }

  2. #2
    Registered User
    Join Date
    Apr 2013
    Posts
    1,342
    Assuming this is C and not C++, all of your variables need to be declared at the start of the function, so move int PowerValue; before or after the int X; .

  3. #3
    Registered User
    Join Date
    May 2013
    Posts
    23
    So I moved the int Powervalue; before int X;. I am getting new warnings i.e. C4700: Uninitialzied local variable 'PowerValue' Used and also get same error for 'NumbertoMultiply'

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,303
    That is because you forgot to pass a pointer to scanf_s on both occasions.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    May 2013
    Posts
    23
    Thank you! Laserlight

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. error C2065: undeclared identifier
    By Sarge in forum Windows Programming
    Replies: 2
    Last Post: 02-19-2012, 03:22 PM
  2. error C2065: undeclared identifier
    By decxan in forum C++ Programming
    Replies: 2
    Last Post: 02-14-2011, 01:42 PM
  3. error C2065: undeclared identifier PLEASE HELP!
    By dyelax in forum C++ Programming
    Replies: 13
    Last Post: 10-12-2009, 12:50 PM
  4. error C2065 undeclared identifier
    By scott27349 in forum C++ Programming
    Replies: 6
    Last Post: 03-10-2002, 04:22 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21