Re: [OT] C programming, variable size array

2003-12-14 Thread Micha Feigin
On Fri, Dec 12, 2003 at 08:38:18PM +0200, Aryan Ameri wrote: > Hi There: > > I am a first year CS student, learning C. A while ago I was asked this > question from a fellow friend of mine: > > "Write a program, which promts the uset to enter some numbers. The user > should terminate the sequenc

debian community (was Re: [OT] C programming, variable size array)

2003-12-14 Thread Clive Standbridge
On Sat 13 Dec 2003 08:13:09 +(-0500), Paul Morgan wrote: > > BTW, the debian community deserves a lot of credit for their QA work. > Doing QA sucks for the most part, and most folks do their level best to > avoid being part of it. And yet debian, this cloud of volunteers from all > over the

Re: [OT] C programming, variable size array

2003-12-13 Thread Nunya
On Sat, Dec 13, 2003 at 08:53:50PM -0800, Nunya wrote: > I'm almost positive the prof. just wanted the guy to use malloc s/malloc/malloc+realloc/ -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Re: [OT] C programming, variable size array

2003-12-13 Thread Nunya
On Sat, Dec 13, 2003 at 09:33:46PM -0700, Paul E Condon wrote: > cheating. But, from my experience as a univerisity professor, I know > that the 'rules of the game' are rather different for homework than > they are for the real world. A homework problem that is of the form " > construct a system th

Re: [OT] C programming, variable size array

2003-12-13 Thread Paul E Condon
On Sat, Dec 13, 2003 at 12:31:00AM -0600, Alex Malinovich wrote: > On Fri, 2003-12-12 at 15:00, Aryan Ameri wrote: > > On Friday 12 December 2003 22:38, Alex Malinovich wrote: > > > On Fri, 2003-12-12 at 14:04, Wesley J Landaker wrote: > > > > On Friday 12 December 2003 11:38 am, Aryan Ameri wrote:

Re: [OT] C programming, variable size array

2003-12-13 Thread Hugo Vanwoerkom
Debian User wrote: if you really have to do it in a low-level language, do it in assembly native to that processor. you can even write them inline within your C code. asm(" mnemonic_instruction operand, operand"); Debian User wrote: > if you really have to do it in a low-level language, do it

Re: [OT] C programming, variable size array

2003-12-13 Thread Paul Morgan
On Fri, 12 Dec 2003 16:57:12 -0500, Hubert Chan wrote: > > >> "John" == John Smith <[EMAIL PROTECTED]> writes: > > John> #include > John> int main > John> ( > John>int nNumberofArguments, > > Your variable names are too long, which decreases readability. Having > such a long name do

Re: [OT] C programming, variable size array

2003-12-13 Thread Paul Morgan
On Fri, 12 Dec 2003 17:56:54 -0700, Monique Y. Herman wrote: > On Fri, 12 Dec 2003 at 23:40 GMT, Paul Morgan penned: > [snip] >> >> In the real world: >> >> Do the simplest thing that is consistent with the specification. >> Someone, whose skill level you can't predict, is going to have to >> ma

Re: [OT] C programming, variable size array

2003-12-13 Thread Scarletdown
What the? How did that end up getting sent to this group? Anyways, please disregard that message, as It is obviously just a screw up on my part during my attempts to get outbound email working properly. On 12 Dec 2003 at 22:35, Scarletdown FeatherTail wrote: > d > q > > > -- > To UNSUBS

Re: [OT] C programming, variable size array

2003-12-13 Thread Scarletdown FeatherTail
d q -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Re: [OT] C programming, variable size array

2003-12-12 Thread Alex Malinovich
On Fri, 2003-12-12 at 15:00, Aryan Ameri wrote: > On Friday 12 December 2003 22:38, Alex Malinovich wrote: > > On Fri, 2003-12-12 at 14:04, Wesley J Landaker wrote: > > > On Friday 12 December 2003 11:38 am, Aryan Ameri wrote: > > > > Hi There: > > > > Hmmm... sounds a lot like a homework problem.

Re: [OT] C programming, variable size array

2003-12-12 Thread Monique Y. Herman
On Fri, 12 Dec 2003 at 23:40 GMT, Paul Morgan penned: [snip] > > In the real world: > > Do the simplest thing that is consistent with the specification. > Someone, whose skill level you can't predict, is going to have to > maintain it after you. Corollary: Regardless of the skill level of the pe

Re: [OT] C programming, variable size array

2003-12-12 Thread Frank Gevaerts
On Fri, Dec 12, 2003 at 08:38:18PM +0200, Aryan Ameri wrote: > Hi There: > > I am a first year CS student, learning C. A while ago I was asked this > question from a fellow friend of mine: > > "Write a program, which promts the uset to enter some numbers. The user > should terminate the sequenc

Re: [OT] C programming, variable size array

2003-12-12 Thread Paul Morgan
On Fri, 12 Dec 2003 20:38:18 +0200, Aryan Ameri wrote: > Hi There: > > I am a first year CS student, learning C. A while ago I was asked this > question from a fellow friend of mine: > > "Write a program, which promts the uset to enter some numbers. The user > should terminate the sequence of

Re: [OT] C programming, variable size array

2003-12-12 Thread Hubert Chan
> "Aryan" == Aryan Ameri <[EMAIL PROTECTED]> writes: [...] Aryan> About initializing the array as static, well I thought that way, Aryan> when I reinitialize it, I would be able to save it's contents (if Aryan> you know what I mean). I was afraid that if it was a automatic Aryan> array, when

Re: [OT] C programming, variable size array

2003-12-12 Thread Wesley J Landaker
On Friday 12 December 2003 1:41 pm, Aryan Ameri wrote: > On Friday 12 December 2003 22:04, Wesley J Landaker wrote: > > Something like this would work if you fill in some of the blanks: > > > > int main() { > > int *array = malloc(sizeof(int)); > > int size = 0; > > printf("Enter Number\n");

Re: [OT] C programming, variable size array

2003-12-12 Thread Colin Watson
On Fri, Dec 12, 2003 at 10:21:36PM +0100, John Smith wrote: > #include > > int main > ( >int nNumberofArguments, >char* apszArgument [] > ) Hungarian notation! Ugh! -- Colin Watson [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] wi

Re: [OT] C programming, variable size array

2003-12-12 Thread Hubert Chan
> "John" == John Smith <[EMAIL PROTECTED]> writes: John> #include John> int main John> ( John>int nNumberofArguments, Your variable names are too long, which decreases readability. Having such a long name does not convey any more information than a shorter name such as "numArgs" (or

Re: [OT] C programming, variable size array

2003-12-12 Thread Hubert Chan
> "Wesley" == Wesley J Landaker <[EMAIL PROTECTED]> writes: [...] Wesley> It would be better to allocate memory in chunks, ... Yes. If you reallocate for every number you read, then it takes O(n^2) time to read n numbers (assuming realloc has to relocate the data every time). If you make y

Re: [OT] C programming, variable size array

2003-12-12 Thread Hubert Chan
> "Alex" == Alex Malinovich <[EMAIL PROTECTED]> writes: [...] Alex> And I wouldn't even bother putting the linked list into an array Alex> in the first place. If you write a good linked list implementation Alex> (which, as I said, would be a good exercise) it will already Alex> support all of

Re: [OT] C programming, variable size array

2003-12-12 Thread Mark Roach
On Fri, 2003-12-12 at 16:00, Aryan Ameri wrote: [...] > To the person who suggested the linked-list thing to me. Thanks very > much. I don't know what they are yet, but it seems something really > interesting. I'll go back to my cave now, to study them. Hi, another thing you might want to check

Re: [OT] C programming, variable size array

2003-12-12 Thread Aryan Ameri
On Friday 12 December 2003 22:38, Alex Malinovich wrote: > On Fri, 2003-12-12 at 14:04, Wesley J Landaker wrote: > > On Friday 12 December 2003 11:38 am, Aryan Ameri wrote: > > > Hi There: > > Hmmm... sounds a lot like a homework problem... =) > > Yes, it does... :) See, this is what I was afrai

Re: [OT] C programming, variable size array

2003-12-12 Thread Aryan Ameri
On Friday 12 December 2003 22:04, Wesley J Landaker wrote: > On Friday 12 December 2003 11:38 am, Aryan Ameri wrote: > > #include > > > > main() > > { > > int tmp, cnt = 0; > > static int arr[cnt]; > > printf( "Enter Number\n"); > > scanf( "%d", &tmp); > > while ( (tmp = getchar() ) != EOF ) { >

Re: [OT] C programming, variable size array

2003-12-12 Thread Nunya
On Fri, Dec 12, 2003 at 08:38:18PM +0200, Aryan Ameri wrote: > > "Write a program, which promts the uset to enter some numbers. The user > should terminate the sequence of numbers by entering EOF character. The > program should put numbers entered by the user in to a 1D array". The real answer

Re: [OT] C programming, variable size array

2003-12-12 Thread John Smith
#include int main ( int nNumberofArguments, char* apszArgument [] ) { int nReturncode = 0 ; int* pnStorage = NULL ; int* pnTmp = NULL ; int nNumberofelements = 0 ; int nNumberofreadfields = 0 ; int nCounter = 0 ; int nInput = 0 ; while ((nReturncode == 0) && ((nN

Re: [OT] C programming, variable size array

2003-12-12 Thread Wesley J Landaker
On Friday 12 December 2003 1:46 pm, Debian User wrote: > if you really have to do it in a low-level language, do it in > assembly native to that processor. you can even write them inline > within your C code. > > asm(" mnemonic_instruction operand, operand"); > Hey, I wouldn't be surprised if some

Re: [OT] C programming, variable size array

2003-12-12 Thread Wesley J Landaker
On Friday 12 December 2003 1:42 pm, s. keeling wrote: > Incoming from Wesley J Landaker: > Content-Description: signed data > > > On Friday 12 December 2003 11:38 am, Aryan Ameri wrote: > > > I am a first year CS student, learning C. A while ago I was asked > > > this question from a fellow friend

Re: [OT] C programming, variable size array

2003-12-12 Thread Debian User
if you really have to do it in a low-level language, do it in assembly native to that processor. you can even write them inline within your C code. asm(" mnemonic_instruction operand, operand"); At Friday, 12 December 2003, Alex Malinovich <[EMAIL PROTECTED] shack.net> wrote: >On Fri, 2003-12

Re: [OT] C programming, variable size array

2003-12-12 Thread s. keeling
Incoming from Wesley J Landaker: Content-Description: signed data > On Friday 12 December 2003 11:38 am, Aryan Ameri wrote: > > > > I am a first year CS student, learning C. A while ago I was asked > > this question from a fellow friend of mine: > > Hmmm... sounds a lot like a homework problem...

Re: [OT] C programming, variable size array

2003-12-12 Thread Alex Malinovich
On Fri, 2003-12-12 at 14:04, Wesley J Landaker wrote: > On Friday 12 December 2003 11:38 am, Aryan Ameri wrote: > > Hi There: > > > > I am a first year CS student, learning C. A while ago I was asked > > this question from a fellow friend of mine: > > > > "Write a program, which promts the uset to

Re: [OT] C programming, variable size array

2003-12-12 Thread Wesley J Landaker
On Friday 12 December 2003 11:38 am, Aryan Ameri wrote: > Hi There: > > I am a first year CS student, learning C. A while ago I was asked > this question from a fellow friend of mine: > > "Write a program, which promts the uset to enter some numbers. The > user should terminate the sequence of numb

[OT] C programming, variable size array

2003-12-12 Thread Aryan Ameri
Hi There: I am a first year CS student, learning C. A while ago I was asked this question from a fellow friend of mine: "Write a program, which promts the uset to enter some numbers. The user should terminate the sequence of numbers by entering EOF character. The program should put numbers ent