global 2d dynamic arrays

Started by
1 comment, last by werdy666 22 years ago
hi, i'm a newbie so forgive me for asking a basic question. I have a dynamic 2d array that is created after reading in a file to decide how big the array will be. its basically an array to hold different words. the first number being the word and the second number being 80 to have plenty of room for the letters. My problem is that the way i have made the array, well it won't let me access it from another function. To best describe this i will show u some code. char **szLine; this line near start of program. loadfile() ..... char **szLine = new char*[num_words]; for(int n = 0;n I call loadfile from main. its a win32 console program. After this all happens it comes back to main and i call game(); In game() the szLine[][] does not exist and my program crashes. "extern" will not work for me and I can't find anywhere on the messages boards here that helps me. Can someone help me make szLine global, or give me hints and suggestions on what i could try or learn. I would prefer to stick with C cause it is more clearer than C++ to me. Thank you for your time and help werdy666 [edited by - werdy666 on April 18, 2002 6:58:37 AM] [Edit: Don't use 'i' as an index value outside source boxes. The board interprets it as italics.] [edited by - Oluseyi on April 18, 2002 7:04:17 AM]
Advertisement
chas **szLine = 0; // globalint main(...){ ... return 0;}...int game(...){ ... return 0;} 


[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! | Asking Smart Questions | Internet Acronyms ]
Thanks to Kylotan for the idea!
thankyou. Its amazing when something that seems so hard, turns out to be so easy!! lol

werdy666

This topic is closed to new replies.

Advertisement