C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 08-27-2008, 12:36 PM   #31
subminimalist
 
MK27's Avatar
 
Join Date: Jul 2008
Location: NYC
Posts: 3,944
gcc 4.1.2 for i386-redhat-linux

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;
     }
Sorry for wasting so much time...like I said, bullheaded and new to C. But I did pick up some stuff along the way.
__________________

Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS
MK27 is offline   Reply With Quote
Old 08-27-2008, 12:38 PM   #32
C++ Witch
 
laserlight's Avatar
 
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   Reply With Quote
Reply

Tags
arrays, functions, structures

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 05:44 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

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