Newbee: Define a struct with scoop outside file?

This is a discussion on Newbee: Define a struct with scoop outside file? within the C Programming forums, part of the General Programming Boards category; Hi all! I am a newbee to ANSI C and have got stuck on struct. If I define a struct ...

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    9

    Newbee: Define a struct with scoop outside file?

    Hi all!
    I am a newbee to ANSI C and have got stuck on struct.
    If I define a struct like:
    Code:
    struct myStruct{
          int aMember;
          int twoMember;
    };
    The scoop for myStruct is within that file, right?
    But if I want to be able to declare one myStruct in anoher file, how do I define myStruct to make the scoop be the entire program?

    Many thanks!
    Marcux

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,672
    Put the struct definition in a header and #include the header in each source file that needs it.
    I used to be an adventurer like you... then I took an arrow to the knee.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,041
    BTW, the correct spelling is scope. scoop is what you do with a spoon (among other things).
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Accessing syscalls from C
    By lilcoder in forum C Programming
    Replies: 17
    Last Post: 09-19-2007, 02:27 PM
  2. NAQ: Everything you never wanted to know about CPP
    By evildave in forum C Programming
    Replies: 21
    Last Post: 12-12-2005, 09:56 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Help getting multiple keypresses in a DOS compiler
    By Nongan in forum Game Programming
    Replies: 2
    Last Post: 04-01-2005, 09:07 PM
  5. DOS, Serial, and Touch Screen
    By jon_nc17 in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 01-08-2003, 03:59 PM

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