calling a function with a pointer to a struct

This is a discussion on calling a function with a pointer to a struct within the C++ Programming forums, part of the General Programming Boards category; I am trying to wrap my noodle around the whole pointer concept here. I want call the function fun1 with ...

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    12

    calling a function with a pointer to a struct

    I am trying to wrap my noodle around the whole pointer concept here. I want call the function fun1 with a pointer. What syntax do I use? What I doing wrong?

    I get this error when I try to compile
    Code:
    boohoo.cpp: IN function 'int main(int, char**)':
    boohoo.cpp 21: error: expected primary-expression before ')' token

    Code:
     
    #include <iostream>
    
    
    using namespace std;
    
    struct myStruct
    {
    	long * stuff1;
    	long   stuff2;
    	long   stuff3;
    };
    
    void fun1(myStruct* workplz);
    
    int main(int argc, char* argv[])
    	{
    	
    	myStruct workplz;
    
    	
    	fun1(workplz*);
    	
    	}//end main
    	
    void fun1 (myStruct* workplz)
    {
    	cout<<"it works."<<endl;
    }
    any help would be great

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,739
    Code:
    fun1(&workplz);
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 02:07 AM
  2. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  3. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 09:18 AM
  4. struct pointer to function syntax
    By kermit in forum C Programming
    Replies: 2
    Last Post: 03-21-2004, 03:01 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM

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