Thread: calling a function with a pointer to a struct

  1. #1
    Registered User
    Join Date
    Mar 2006

    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
    boohoo.cpp: IN function 'int main(int, char**)':
    boohoo.cpp 21: error: expected primary-expression before ')' token

    #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;
    	}//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
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    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, 03: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, 10:18 AM
  4. struct pointer to function syntax
    By kermit in forum C Programming
    Replies: 2
    Last Post: 03-21-2004, 04:01 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM