Jump to content

Check out our Community Blogs


Member Since 08 Jul 2010
Offline Last Active Sep 19 2011 03:39 AM

Posts I've Made

In Topic: why is that different? [solved]

28 November 2010 - 04:10 PM

In this line:
*names[i] = (char*)malloc(sizeof(char)*50);
Operator [] has higher precedence than dereference operator *. You should change the line into this:
(*names)[i] = (char*)malloc(sizeof(char)*50);

In Topic: C program to detect prime numbers

27 November 2010 - 11:22 AM

Just to add a reference to Sieve of Eratosthenes algorithm for finding all prime numbers in range 2-N for any given N. It operates very fast, and can be memory optimized by spending 1 bit per number, meaning that N/8 bytes are required to find all prime numbers up to N.

In Topic: Error in folder information--need help

27 November 2010 - 01:25 AM

I suppose that is compile error. Two things are required:
1. DirectoryInfo instead of directoryinfo
2. Refer the class either its full name (System.IO.DirectoryInfo) or put using System.IO; at the beginning of the file.

In Topic: Sending arrays as parameter to other functions

18 November 2010 - 06:22 AM

Sorry, I said to pass list by value but that has to be by reference - in that way you can change head pointer in the List object and have changed list on return.

In Topic: Sending arrays as parameter to other functions

18 November 2010 - 04:30 AM

Not really - sorting the list may cause head node to be changed.

I prefer creating another structure, e.g. called List, which only contains pointer to head element: Node* head;

Then you can pass the List variable (by value) to the sort method, and that will rearrange Node instances into a different sequence, possibly changing the head node too, and List variable will reflect the changes.

Same effect can be obtained with passing reference to head element pointer, e.g. like this: void placeWordsInBuckets(Node **headPtr).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download