Thread: Why does this only work when

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    109

    Question Why does this only work when

    Why does this a.x=entery; only work in int main() and not any other function?
    OS:- XP
    Compiler:- MSVC++ 6 or DJGPP or Dev-c++ (Mingw)

  2. #2
    Registered User
    Join Date
    Sep 2002
    Posts
    137
    Did you declare your structure as global or local? If its only local then make it global, that might do it.
    http://uk.geocities.com/ca_chorltonkids

  3. #3
    Registered User
    Join Date
    Aug 2002
    Posts
    109

    Its Global

    No my structure is global
    OS:- XP
    Compiler:- MSVC++ 6 or DJGPP or Dev-c++ (Mingw)

  4. #4
    Green Member Cshot's Avatar
    Join Date
    Jun 2002
    Posts
    892
    Post some code.
    Try not.
    Do or do not.
    There is no try.

    - Master Yoda

  5. #5
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    Variable entery is also global?
    Variable a is a structure and not a pointer to it?
    Variable a has a member x?

    In other words, give some more details on how a is declared and defined. Also check variable entery. Some more code would be useful.

  6. #6
    Registered User
    Join Date
    Aug 2002
    Posts
    109

    I worked it out

    When I was trying to write to a.x in a function I had declared a char variable before it in the same function and this seemed to mess it up. When i took the char variable out it worked!

    Does anyone have any resons why?
    OS:- XP
    Compiler:- MSVC++ 6 or DJGPP or Dev-c++ (Mingw)

  7. #7
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Not without seeing the code, unless you want someone to make an educated guess.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  8. #8
    Registered User
    Join Date
    Aug 2002
    Posts
    109

    It doesn't matter

    It doesn't matter anymore I have a bigger problem click here


    Thanks anyway for the help
    OS:- XP
    Compiler:- MSVC++ 6 or DJGPP or Dev-c++ (Mingw)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. strcmp returning 1...
    By Axel in forum C Programming
    Replies: 12
    Last Post: 09-08-2006, 07:48 PM
  2. getline() don't want to work anymore...
    By mikahell in forum C++ Programming
    Replies: 7
    Last Post: 07-31-2006, 10:50 AM
  3. Why don't the tutorials on this site work on my computer?
    By jsrig88 in forum C++ Programming
    Replies: 3
    Last Post: 05-15-2006, 10:39 PM
  4. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM
  5. DLL __cdecl doesnt seem to work?
    By Xei in forum C++ Programming
    Replies: 6
    Last Post: 08-21-2002, 04:36 PM