Thread: Invalid type of unary '*'

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    3

    Question Invalid type of unary '*'

    Good day!
    I'm having problems with my lab activity(which I can't find the solution), it's already graded but I have to finish it and to make it function.
    Is there something wrong with the way I reallocated space? Please help me find the solution for this.
    I have problems during compile time, it says: invalid type argument of unary '*'
    Code:
    int getInputs(int **ptr)
    {   int x, w;
    	int i=0;
    	int y=0;
    	int *pTemp;	
    	
    		
    		*ptr = malloc(sizeof(int)*10);
    		
    		do
    		{	print("enter number here:");
    			scanf("%d", &x);
    		if (i<10)	
    		{	if(x>0)
    			{	*(*ptr + i) = x;
    				i++;
    				y++;
    			}
    				else	if(x==0)
    						{	*(*ptr + i) = x;
    							i++;
    						}
    		}
    		else	
    			{	w=i++;
    				if(x>0)
    				{	
    					pTemp = realloc(ptr, sizeof (int) * 10);
    					*(*pTemp + w ) = x; // invalid type argument of unary '*'
    					y++;
    					w++;
    				}
    					else	if(x==0)
    						{	*(*pTemp + w ) = x; // invalid type argument of unary '*'
    							w++;
    						}
    			
    			}
    		}while(x>=0);
    		
    		return y;
    }
    PS.

  2. #2
    Registered User
    Join Date
    Mar 2009
    Posts
    399
    Change it to:
    Code:
    *(pTemp + w )

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    3
    Quote Originally Posted by Memloop View Post
    Change it to:
    Code:
    *(pTemp + w )
    I already changed it that way. It now says [Linker Error]:Undefined reference to print.
    1d returned 1 exit status.

  4. #4
    Registered User
    Join Date
    Mar 2009
    Posts
    399
    There's no "print" function in standard C. Use puts or printf.

  5. #5
    Registered User
    Join Date
    Jan 2010
    Posts
    3
    Quote Originally Posted by Memloop View Post
    There's no "print" function in standard C. Use puts or printf.
    OMG. Thank you. I didn't see it coming.

  6. #6
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by Memloop View Post
    There's no "print" function in standard C. Use puts or printf.

    Memloop - STOP!

    You're giving away all our Ckrets!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sorting the matrix question..
    By transgalactic2 in forum C Programming
    Replies: 47
    Last Post: 12-22-2008, 03:17 PM
  2. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  3. strings Vs. Char pointers
    By aijazbaig1 in forum C Programming
    Replies: 49
    Last Post: 02-13-2008, 09:51 AM
  4. Question on l-values.
    By Hulag in forum C++ Programming
    Replies: 6
    Last Post: 10-13-2005, 04:33 PM
  5. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM

Tags for this Thread