Search Results

Showing results 1 to 40 of 251
Search took 0.03 seconds.
Search: Posts Made By: dwks
Forum: C++ Sep 8th, 2009
Replies: 13
Views: 569
Posted By dwks
Well then use "/home/USER/.todo" or better yet "~/.todo". Saying "/.todo" is like saying "/usr" or "/home"; it gets you a file relative to the root of the filesystem, which as I have said before, is...
Forum: C++ Sep 5th, 2009
Replies: 4
Views: 286
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 5th, 2009
Replies: 13
Views: 569
Posted By dwks
Yes, but "/.todo" is a hidden file *in the root of the drive*, and it's extremely probable that you don't want to be writing there. If you want a hidden file, fine, use ".todo" or "./todo" to...
Forum: C++ Sep 3rd, 2009
Replies: 4
Views: 286
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++ Sep 3rd, 2009
Replies: 13
Views: 569
Posted By dwks
I'm also thinking that this
string todo = "/.todo.txt";

should be "./" instead of "/.".
Forum: C++ Aug 31st, 2009
Replies: 5
Views: 356
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: 218
Posted By dwks
This page (http://www.instant-registry-fixes.org/troubleshooting-and-preventing-ntdlldll-errors/) says that ntdll.dll is "a Native API file of Microsoft operating systems and it contains NT kernel...
Forum: C Aug 31st, 2009
Replies: 2
Views: 254
Posted By dwks
char filenames[fcount][16];
You're declaring a variable-length array here. It's not standard C89 to do that. If I were you I'd just declare the array as
char filenames[MAX_FCOUNT][16];

Also:
...
Forum: C Aug 31st, 2009
Replies: 2
Views: 205
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: 2
Views: 585
Posted By dwks
A constant variable can't be changed after initialization. If you didn't initialize it, too bad, you still can't change it. (If you compiler is a good one, it may warn you that you haven't...
Forum: C++ Jun 8th, 2009
Replies: 5
Views: 254
Posted By dwks
I've really told you all you need to know. I'll give you some more details, but you'll have to do some searching . . . .

Three steps.

Open the file. You use ifstream to do this, it's not hard....
Forum: C Jun 8th, 2009
Replies: 14
Solved: File handling
Views: 822
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++ Jun 8th, 2009
Replies: 2
Views: 758
Posted By dwks
Too bad you're not using PHP. :) http://ca2.php.net/filesize

But it seems like it might not be possible: http://bytes.com/groups/php/595984-filesize-not-reading-http-pages

On the other hand,...
Forum: C++ Jun 8th, 2009
Replies: 5
Views: 254
Posted By dwks
Well, that's not too difficult. You could open the file, read it line-by-line, and print only those lines which contain the word "WARNING", for example. If you wanted to be more robust, you could...
Forum: C++ Jun 8th, 2009
Replies: 2
Views: 896
Posted By dwks
Did you try google? There seem to be a lot of hits relating to this. http://www.google.ca/search?q=sdl_ttf+opengl

You can use SDL_ttf's TTF_RenderText_Blended to get smoothed SDL text surfaces. I...
Forum: C Sep 6th, 2008
Replies: 1
Views: 747
Posted By dwks
Why is root a global variable? As far as I can see, it doesn't need to be, and it's just causing confusion because several functions take a root parameter.
Forum: C Sep 4th, 2008
Replies: 11
Views: 1,827
Posted By dwks
Declaring variables inside for loop initialization sections is indeed C99-only. I wouldn't do it if I were you.


double just has more precision (usually). Oftentimes, a float is 4 bytes and a...
Forum: C++ Aug 15th, 2008
Replies: 3
Views: 1,352
Posted By dwks
while ( !feof(ep) )
{
fgets(registryHive, MAX_PATH, ep);

Note that this is not a good idea...
Forum: C Aug 13th, 2008
Replies: 14
Views: 1,276
Posted By dwks
You can even use fancy preprocessor macros and so on to replace the malloc()/free() calls in existing code with your own functions.

BTW, __LINE__, __FILE__, __DATE__, and __TIME__ are all standard...
Forum: C Aug 13th, 2008
Replies: 4
Views: 1,599
Posted By dwks
Why don't you use the quadratic formula (http://en.wikipedia.org/wiki/Quadratic_equation#Quadratic_formula)? If all of the equations are quadratic, it should work.

You can do square roots in C...
Forum: C Aug 13th, 2008
Replies: 4
Solved: fibonacci
Views: 641
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: 641
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: 10
Views: 971
Posted By dwks
You don't want a semicolon after a while loop:
while( number<= 0 ); {
->
while( number<= 0 ) {
Forum: C++ Aug 5th, 2008
Replies: 9
Views: 3,364
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,545
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: Perl Jul 24th, 2008
Replies: 5
Views: 1,027
Posted By dwks
Correction: it's difficult in C and C++, but of course Perl would have a module for it. ;) It looks like a very useful one, too . . . .
Forum: C++ Jul 24th, 2008
Replies: 10
Views: 998
Posted By dwks
switch (choice)
{
case '1':
saveGame();
case '2':
switch (missionNumber)
{
case 1:
...
Forum: C Jul 22nd, 2008
Replies: 10
Views: 2,538
Posted By dwks
My only suggestion is to try a profiler so that you can see exactly where your program is spending all of its time. If you have access to the code from the other program, profiling it as well might...
Forum: C Jul 22nd, 2008
Replies: 3
Views: 501
Posted By dwks
What are you forgetting here?
for(j=0;j<41;j++)
for(i=0;i<79;)
txt[j][i]=32;
Hint: it's an infinite loop . . . .

And it's a lot easier to use character constants like ' ' and '\r' in your...
Forum: C Jul 22nd, 2008
Replies: 2
Views: 494
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 22nd, 2008
Replies: 10
Views: 927
Posted By dwks
@Adak: I already mentioned that, though admittedly it was buried in my long post.

The main logical problem with your code still exists. Numbers aren't the same thing as strings. You can't have an...
Forum: Perl Jul 16th, 2008
Replies: 5
Views: 1,027
Posted By dwks
You can read from and write to the same file at once, but it's difficult.

You're best off creating a copy of the file and modifying that, then replacing the original file with the modified one, as...
Forum: C Jul 16th, 2008
Replies: 7
Views: 1,926
Posted By dwks
for loops generally have three sections. You've forgotten the increment section. :)

You're also missing a closing parentheses on the strlen() call . . . .

But we know what you mean. :)
char...
Forum: C++ Jul 16th, 2008
Replies: 8
Solved: Alignement
Views: 784
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,588
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: 10
Views: 998
Posted By dwks
Use code=c++ in your code tags to get syntax highlighting. It makes the code a lot easier to read.

iostream.h doesn't actually exist (according to the C++ standard). Consider using
#include...
Forum: C Jul 16th, 2008
Replies: 3
Views: 1,105
Posted By dwks
while( line % 55 != 0 )
Note that 0 % 55 is 0, so you'll pause before printing anything, and then display 55 lines ad infinitum. The best solution is probably to use something like this:
while(...
Forum: C Jul 16th, 2008
Replies: 10
Views: 927
Posted By dwks
That last post was getting crowded so I thought I'd start another one -- especially since it's a higher-level one.

Since you're trying to handle both numbers and strings, why not have two separate...
Forum: C Jul 16th, 2008
Replies: 10
Views: 927
Posted By dwks
GCC doesn't like your code.
sort.c: In function ‘read_list’:
sort.c:13: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘int *’
sort.c: In function ‘insert_sort’:
sort.c:75:...
Forum: C Jul 16th, 2008
Replies: 5
Views: 4,615
Posted By dwks
You can read image files in your program in a standard way, if you want to write the reader yourself. wotsit.org is a good reference for this, as already mentioned.

Or you can use a library to...
Showing results 1 to 40 of 251

 


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

©2003 - 2009 DaniWeb® LLC