![]() |
| | #31 |
| subminimalist Join Date: Jul 2008 Location: NYC
Posts: 3,944
| What I really should have been doing all along, as laserlight eventually points out in another thread, was this Code: struct thestruct {
[...]
} *ray;
int main () {
short int nofl, i;
[...determine nofl]
ray = malloc(nofl * sizeof(*ray));
for (i=0; i<nofl; i++) {
ray[i].member = whatever;
}
__________________ Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS |
| MK27 is offline | |
| | #32 |
| C++ Witch Join Date: Oct 2003 Location: Singapore
Posts: 10,364
| Incidentally, must ray really be a global variable? If feasible, make it a local variable. Also, remember to free() what you malloc(), and to check that malloc() does not return NULL before using ray as a dynamically allocated array.
__________________ C + C++ Compiler: MinGW port of GCC Build + Version Control System: SCons + Bazaar Look up a C/C++ Reference and learn How To Ask Questions The Smart Way |
| laserlight is online now | |
![]() |
| Tags |
| arrays, functions, structures |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| IF CONDITION plese help | birumut | C Programming | 12 | 03-06-2009 09:48 PM |
| making it portable.....? | ShadeS_07 | C Programming | 11 | 12-24-2008 09:38 AM |
| get keyboard and mouse events | ratte | Linux Programming | 10 | 11-17-2007 05:42 PM |
| Simple C question: user input to repeat a loop | evernaut | C Programming | 2 | 11-18-2006 09:23 AM |
| Drawing tables in C | stanoman | C Programming | 5 | 10-09-2003 10:14 AM |