Search Results

Showing results 1 to 16 of 16
Search took 0.01 seconds.
Search: Posts Made By: dwks ; Forum: C and child forums
Forum: C Aug 31st, 2009
Replies: 2
Views: 214
Posted By dwks
You can't assign anything inside a structure declaration. A structure declaration just defines a type. It's like a blueprint; you're telling the compiler, "if I ask you to create a Something, this is...
Forum: C Jun 8th, 2009
Replies: 14
Solved: File handling
Views: 855
Posted By dwks
Well, it has one advantage over a return value -- you have to pass in an address, whereas you could ignore a return value. :) I don't think that's how I would write it, though.
Forum: C Aug 13th, 2008
Replies: 4
Solved: fibonacci
Views: 663
Posted By dwks
/* replaced 0 by 1 */
Depending on who you ask, the first fibonacci number can be 0 or 1. (Personally, I'd agree with you and have it 1.)

Why not use more descriptive names than num1, num2, etc?
Forum: C Aug 13th, 2008
Replies: 4
Solved: fibonacci
Views: 663
Posted By dwks
if(fib = fnum)

Try ==. = is for assignment, == is for comparison. (Your compiler should warn you about this if you enable warnings.)

Plus I don't think this is what you want.
for (fib=1;...
Forum: C Jul 22nd, 2008
Replies: 2
Views: 507
Posted By dwks
You could save the numbers as you find them instead of printing them, say in a char array, and then print that array in reverse. On the other hand, it would probably be better to use a different...
Forum: C Jul 16th, 2008
Replies: 8
Views: 1,828
Posted By dwks
Yeah, most of the time it's a good idea. Sorry I didn't explain it further.


Yes. Accessing such memory could lead to data corruption or at the very least segmentation faults.


Correct.

...
Forum: C Jul 16th, 2008
Replies: 8
Views: 1,828
Posted By dwks
ex_1.emotion_options = (char **)malloc(sizeof(char *[MAX_EMOTION_SIZE]));
That's uninitialized, so if you don't fill in MAX_EMOTION_SIZE elements of that array, then this will be freeing random...
Forum: C Jul 2nd, 2008
Replies: 24
Views: 2,766
Posted By dwks
Sorry to go behind jephthah's back here, but if this is your original structure
typedef struct ip_header{
unsigned char headlen:4; // header len
unsigned char ver:4; // version
unsigned...
Forum: C Jul 2nd, 2008
Replies: 8
Views: 690
Posted By dwks
Don't forget Dev-C++: http://bloodshed/net/devcpp.html

But I doubt that's the problem, if Ancient Dragon encountered the same issue.
Forum: C Oct 20th, 2007
Replies: 13
Views: 4,740
Posted By dwks
Something like this. I've glossed over details that you seem to already understand.

Declare an array to hold the letter counts one element for each letter, with each element initialized to zero....
Forum: C Oct 20th, 2007
Replies: 13
Views: 4,740
Posted By dwks
if(letter[i]==str[count])
Think about what you are doing here. You're saying something to the effect of, "if the i-th element of letter[] equals the count-th element of str[] ...". Since you've...
Forum: C Oct 20th, 2007
Replies: 7
Views: 863
Posted By dwks
TRUE is a commonly-defined constant -- windows.h defines it, along with a whole host of other libraries. true is a C++ keyword, and a C99 keyword if you include <stdbool.h>.

So in ordinary, ANSI...
Forum: C Aug 21st, 2007
Replies: 11
Views: 1,782
Posted By dwks
process_values( values, sizeof values / sizeof( int ) );
Consider
process_values( values, sizeof values / sizeof *values );
If you're going to the trouble to use sizeof() to determine how many...
Forum: C Jun 23rd, 2006
Replies: 28
Views: 5,683
Posted By dwks
Put the n2 = atoi(argv[2]); after you check to see if the program got enough arguments (the if(argc != 3)).

Oh yeah . . . and add a semicolon. :)
Forum: C Dec 23rd, 2005
Replies: 27
Views: 4,890
Posted By dwks
[qoute] -> [quote]

time() etc are in <time.h> (for C) or <ctime> (for C++).

struct tm contents: http://members.aol.com/wantondeb/#tmstruct
Forum: C Dec 4th, 2005
Replies: 5
Views: 1,856
Posted By dwks
It's [/code], not [\code]. :)

You're declaring variables in the middle of a block, which is C++/C99.
if((des=fopen(FILENAME,"r"))==NULL)
printf("The file was not opened, HAHA\n");
Might want...
Showing results 1 to 16 of 16

 


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

©2003 - 2009 DaniWeb® LLC