Search Results

Showing results 1 to 30 of 30
Search took 0.03 seconds.
Search: Posts Made By: dwks
Forum: C++ Sep 5th, 2009
Replies: 4
Views: 331
Posted By dwks
#define isn't what you need. #define does compile-time text substitution, as if you'd done a search-replace just before every compilation.


That looks like a reasonable idea. You'll probably want...
Forum: C++ Sep 3rd, 2009
Replies: 4
Views: 331
Posted By dwks
Yes, new members register at an astonishing rate here . . . when I logged in there were six less members than there are now. :)


[Sorry if this is a bit advanced. I assume you're a pretty good...
Forum: C++ Aug 31st, 2009
Replies: 5
Views: 420
Posted By dwks
You use -99 in your input file to indicate end of line, but you seem to expect -999 in your program . . . .

Just a thought: why don't you read in one line at a time, and treat that as the row of a...
Forum: C Aug 31st, 2009
Replies: 2
Views: 227
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: 874
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: 682
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: 682
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++ Aug 5th, 2008
Replies: 9
Views: 3,733
Posted By dwks
The best way to do this is perhaps this: declare a structure representing the information. (Perhaps a header structure, a data one, a tail, and a packet structure that contains all three.)

If you...
Forum: C++ Aug 5th, 2008
Replies: 18
Solved: enum warnings
Views: 1,666
Posted By dwks
What? Never heard of that. Don't tell me,
this don't work
x = bool (x||y) ;
That is C++ only. The C way looks like this.
x = (bool)(x || y);
Perhaps the OP is compiling as C instead of C++.
...
Forum: C Jul 22nd, 2008
Replies: 2
Views: 511
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
Solved: Alignement
Views: 803
Posted By dwks
So your question is, why does structure alignment apply to the last member of a structure?

I think the answer is the same as for why structure alignment exists in the first place. Structure...
Forum: C Jul 16th, 2008
Replies: 8
Views: 1,952
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,952
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: 4
Views: 601
Posted By dwks
In order to use the ifstream fin variable that you declare inside the switch statement, you need to declare it outside the switch statement. For example:
ifstream fin;
switch(choose) {
case 1:
...
Forum: C++ Jul 2nd, 2008
Replies: 27
Views: 2,134
Posted By dwks
http://board.theprogrammingsite.com/viewtopic.php?t=113&sid=57532b7c18db0b6089757cc195c714b4
Forum: C Jul 2nd, 2008
Replies: 24
Views: 2,838
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: 697
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,871
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,871
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: 870
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,813
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++ Sep 14th, 2006
Replies: 4
Views: 11,840
Posted By dwks
I imagine the overhead would not be great (unless your program is written in C++); TC fits on four floppy disks and it runs on an XT computer. But switching to an old compiler just so you can use its...
Forum: C Jun 23rd, 2006
Replies: 28
Views: 5,775
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++ Feb 9th, 2006
Replies: 6
Views: 3,615
Posted By dwks
You have to decrement listSize if you don't want it to print -999. eg
cout <<"Enter a maximum of 100 positive integers ending with -999"<<endl;
readNum (Numbers, listsize);
...
Forum: C Dec 23rd, 2005
Replies: 27
Views: 4,909
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 10th, 2005
Replies: 11
Views: 1,851
Posted By dwks
Sorry, I can't view your file (this stupid computer doesn't have WinZIP!), but I'm going to guess you're not clearing the keyboard buffer.

This will clear the keyboard buffer (it's in C):
int c;...
Forum: C++ Dec 8th, 2005
Replies: 4
Views: 1,256
Posted By dwks
Yes, unless you want a global variable.
Forum: C++ Dec 8th, 2005
Replies: 4
Views: 1,256
Posted By dwks
doctor* Array[5];


for(int i=0;i<2;i++)

Array isn't initialized. And if it was, you're only looping through two of its five elements.
Forum: C Dec 4th, 2005
Replies: 5
Views: 1,881
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...
Forum: C++ Nov 30th, 2005
Replies: 15
Views: 2,450
Posted By dwks
Showing results 1 to 30 of 30

 


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

©2003 - 2009 DaniWeb® LLC