How to convert pointer to value?

This is a discussion on How to convert pointer to value? within the C Programming forums, part of the General Programming Boards category; I have some code like Code: struct mystruct { int stuff; etc... }; typedef mystruct foo; func2(foo a) { } ...

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    119

    How to convert pointer to value?

    I have some code like
    Code:
    struct mystruct
    {
      int stuff;
      etc...
    };
    
    typedef mystruct foo;
    
    func2(foo a)
    {
    }
    
    func1(foo *a)
    {
    }
    
    main()
    {
     foo a;
     func1(&a);
    }
    I want to call func2 from func1, but how do I convert foo* into foo?

  2. #2
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Code:
    func1(foo *a)
    {
       //yara yara yara
       func2(*a);
    }

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,449
    Note that all functions should have a return type.
    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. Ban pointers or references on classes?
    By Elysia in forum C++ Programming
    Replies: 89
    Last Post: 10-30-2007, 03:20 AM
  2. sorting with pointer of pointers to array
    By dunpealslyr in forum C++ Programming
    Replies: 6
    Last Post: 10-01-2007, 11:26 PM
  3. Question About Pointer To Pointer
    By BlitzPackage in forum C++ Programming
    Replies: 2
    Last Post: 09-19-2005, 10:19 PM
  4. Could somebody please help me with this C program
    By brett73 in forum C Programming
    Replies: 6
    Last Post: 11-25-2004, 01:19 AM
  5. towers of hanoi problem
    By aik_21 in forum C Programming
    Replies: 1
    Last Post: 10-02-2004, 01:34 PM

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