Another Pointer

This is a discussion on Another Pointer within the C Programming forums, part of the General Programming Boards category; Can someone please tell what I am doing wrong with this pointer. I keep getting error message undeclared itdentifier. found ...

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    47

    Another Pointer

    Can someone please tell what I am doing wrong with this pointer. I keep getting error message undeclared itdentifier. found int expected point to int.

    Code:
    void Gen2Rand (int*r1p, int*r2p)
    
    		int r1; //First random number
    		int r2; //Second random number
    
    		r1 = 2 + rand() % 11;
    		r2 = 2 + rand() % 11;
    
    	              *r1p = r1;
    	              *r2p = r2;
    
    return (0);

  2. #2
    Epy
    Epy is offline
    Fortran lover Epy's Avatar
    Join Date
    Sep 2009
    Location
    California, USA
    Posts
    960
    I assume you just didn't copy the brackets that enclose the function...

    You do have spaces (int*r1p, int*r2p) in between the ints and the pointer names, right?

    Edit: Also, it's a void function, so you shouldn't be returning an integer.

  3. #3
    Registered User
    Join Date
    Sep 2009
    Posts
    47
    Thanks, but I have the program complete. My mind went blank for a minute.

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,546
    Quote Originally Posted by Epy View Post
    You do have spaces (int*r1p, int*r2p) in between the ints and the pointer names, right?
    The compiler does not care about that, actually.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Following CTools
    By EstateMatt in forum C Programming
    Replies: 5
    Last Post: 06-26-2008, 10:10 AM
  2. Quick Pointer Question
    By gwarf420 in forum C Programming
    Replies: 15
    Last Post: 06-01-2008, 03:47 PM
  3. Parameter passing with pointer to pointer
    By notsure in forum C++ Programming
    Replies: 15
    Last Post: 08-12-2006, 07:12 AM
  4. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  5. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM

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