Thread: Declaring A Global Structure?

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    5

    Declaring A Global Structure?

    say for instance i would like to declare a global structure of data type int char float how do i do that? could u demonstrate using variables and defining the structure for me plz

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quote Originally Posted by runnings View Post
    say for instance i would like to declare a global structure of data type int char float how do i do that? could u demonstrate using variables and defining the structure for me plz
    You do not know how to declare var of type struct or you do not know how to declare global var?
    Which is it?

    And my advice - do not use global vars...
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    A struct is a blueprint. A blueprint can be used wherever you have access to that blueprint.
    So create the blueprint in a header, then include that header wherever you need to use the blueprint.
    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. basic question about global variables
    By radeberger in forum C++ Programming
    Replies: 0
    Last Post: 04-06-2009, 12:54 AM
  2. Global Structure question.
    By tdep in forum C Programming
    Replies: 6
    Last Post: 07-04-2007, 05:59 PM
  3. passing structure arrays to functions?
    By bem82 in forum C Programming
    Replies: 3
    Last Post: 10-30-2006, 06:17 AM
  4. structure ...solution plz????
    By hegdeshashi in forum C Programming
    Replies: 4
    Last Post: 07-24-2006, 09:57 AM
  5. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM