Forum: C Jul 9th, 2009 |
| Replies: 4 Views: 290 He didn't do anything "wrong" as such, but there isn't any need to cast it. |
Forum: C Jun 25th, 2009 |
| Replies: 10 Views: 622 It's practically the same thing, in my example I used a struct anyway. |
Forum: C Jun 24th, 2009 |
| Replies: 10 Views: 622 There's plenty of big-number libraries on the net, or if you have the programming ability, you can write your own big-number class.struct BigInt {
// ...
};
int main( void ) {
} |
Forum: C Jun 14th, 2009 |
| Replies: 8 Views: 431 Ever heard of punctuation (http://www.answers.com/main/ntquery?s=punctuation&gwp=13)?
Anyway, I have to admit, that confused me.
This part:~(~0 << n)will make a binary number containing however... |
Forum: C Jun 12th, 2009 |
| Replies: 9 Views: 436 Why don't you start by giving us a less vague question. What is the program supposed to do? What output are you expecting? Without these details it's hard for us to help. |
Forum: C Jun 2nd, 2009 |
| Replies: 22 Views: 938 Nah! keep them, I found this thread amusing :D |
Forum: C Jun 2nd, 2009 |
| Replies: 22 Views: 938 Shouldn't it be a & and not a &&? Otherwise the && # is pointless. |
Forum: C Jun 2nd, 2009 |
| Replies: 22 Views: 938 >William, regarding your post (#11): I think that int main( void ) is the preferred way in C
I think we're looking into things far too much here. It works now, so let's just leave it at that, OK?... |
Forum: C Jun 2nd, 2009 |
| Replies: 22 Views: 938 Who says using brackets is better? IMO your code was harder to read than the original code. If it were me, I would have written it like this:#include <stdio.h>
int main() {
int color;
... |
Forum: C May 29th, 2009 |
| Replies: 13 Views: 448 If you are working out the biggest number, you have to start off with the smallest possible value and keep looking for a bigger value.
To find the smallest, you have to do the opposite. Start off... |
Forum: C May 29th, 2009 |
| Replies: 13 Views: 448 >what the diff between array[i] and just normal i?
It's two completely different things, i is just an integer, array[i] is the element which is located at the index of i. |
Forum: C May 29th, 2009 |
| Replies: 13 Views: 448 #include <stdio.h>
int FindBiggest(int *arr, int length)
{
int i;
int num = 0;
for (i = 0; i < length; i++) {
if ( arr[i] > num )
num = arr[i]; |
Forum: C May 29th, 2009 |
| Replies: 13 Views: 448 Is there any code you aren't posting? what is FIND_NUM and BIGGEST? You can't use sizeof to work out the length of an array passed to a pointer, instead you have to allow the caller to pass the... |
Forum: C May 21st, 2009 |
| Replies: 15 Views: 1,239 You're wrong. If you pass a NULL pointer to atoi, your program will most lightly crash. If you pass a string such as "12Q34" then it will return 12, as it stops as soon as it reaches the first... |
Forum: C Jan 6th, 2009 |
| Replies: 8 Views: 600 void swapLines(int j, int k)
{
char *temp = malloc(sizeof(char) * 1000);
temp = strings[j]; // What happened to the 1000 chars you just allocated?
strings[j] = strings[k];
strings[k] =... |
Forum: C Dec 27th, 2008 |
| Replies: 7 Views: 528 >There's nothing inherently wrong with returning a duplicated copy of the string in allocated memory
I will agree with that to some extent :icon_wink: but only if the caller knows exactly what... |
Forum: C Dec 27th, 2008 |
| Replies: 7 Views: 528 return strdup(temp);
Bad idea, you should never return a pointer to allocated dynamic memory, as you can quite easily forget to release that memory once you've done with it. The correct way to do... |