Search Results

Showing results 1 to 17 of 17
Search took 0.01 seconds.
Search: Posts Made By: William Hemsworth ; Forum: C and child forums
Forum: C Jul 9th, 2009
Replies: 4
Solved: strdup-casting
Views: 290
Posted By William Hemsworth
He didn't do anything "wrong" as such, but there isn't any need to cast it.
Forum: C Jun 25th, 2009
Replies: 10
Solved: Data Type
Views: 622
Posted By William Hemsworth
It's practically the same thing, in my example I used a struct anyway.
Forum: C Jun 24th, 2009
Replies: 10
Solved: Data Type
Views: 622
Posted By William Hemsworth
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
Posted By William Hemsworth
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
Solved: Weird problem
Views: 436
Posted By William Hemsworth
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
Solved: help me
Views: 938
Posted By William Hemsworth
Nah! keep them, I found this thread amusing :D
Forum: C Jun 2nd, 2009
Replies: 22
Solved: help me
Views: 938
Posted By William Hemsworth
Shouldn't it be a & and not a &&? Otherwise the && # is pointless.
Forum: C Jun 2nd, 2009
Replies: 22
Solved: help me
Views: 938
Posted By William Hemsworth
>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
Solved: help me
Views: 938
Posted By William Hemsworth
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
Posted By William Hemsworth
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
Posted By William Hemsworth
>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
Posted By William Hemsworth
#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
Posted By William Hemsworth
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
Solved: Using sprintf
Views: 1,239
Posted By William Hemsworth
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
Posted By William Hemsworth
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
Posted By William Hemsworth
>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
Posted By William Hemsworth
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...
Showing results 1 to 17 of 17

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC