Search Results

Showing results 1 to 40 of 104
Search took 0.01 seconds.
Search: Posts Made By: Chainsaw ; Forum: C and child forums
Forum: C Feb 2nd, 2005
Replies: 8
Views: 3,946
Posted By Chainsaw
It's no bother at all, but you are right I don't understand what you are attempting. It sounds like you are doing something to these 5 copies and then seeing if doing something to them didn't change...
Forum: C Feb 1st, 2005
Replies: 8
Views: 3,946
Posted By Chainsaw
You could just say....

if (mask_bit == 1)
result = original;
else
resilt = altered_pixel;

Becuase if the mask is one bit and the pixel is 8 bits you'd have to do some fussing with stuff to...
Forum: C Feb 1st, 2005
Replies: 8
Views: 3,946
Posted By Chainsaw
So you have pixels represented as some number of shades of gray. And you want to AND them with something? Why AND? Is this some sort of mask where all ON (black? white?) is a mask to include the...
Forum: C Jan 29th, 2005
Replies: 8
Views: 13,922
Posted By Chainsaw
you could, for example, use printf or sprintf or its ilk. Take a look at the specifications for the strings. You can control right or left justification, leading zeros, number of digits after the...
Forum: C Jan 29th, 2005
Replies: 3
Views: 2,290
Posted By Chainsaw
You want to print this bill on a printer or on disk? On which OS? Are you using MFC, which has extensive printer support built in? Is you app a windowing app or a console app (I assume a windowing...
Forum: C Jan 27th, 2005
Replies: 4
Views: 3,678
Posted By Chainsaw
Dave beat me by one minute! Rats! :-)

Ah, well, great minds.....
Forum: C Jan 27th, 2005
Replies: 4
Views: 3,678
Posted By Chainsaw
how about:

char filename[ 256 ]; // or MAX_PATH or whatever
...
sprintf( filename, "%d.txt", i ); // now filename will be 1.txt, 2.txt, whatever.

and run the loop from 1 to < 6 or 1 to <= 5,...
Forum: C Jan 24th, 2005
Replies: 6
Solved: binary search
Views: 33,004
Posted By Chainsaw
Here is your culpret:

beg=a[0];
end=a[9];

beg should be the bottom of the range to search, in this case 0.
end should be the top of the range to search, in this case n (not 9).

You are...
Forum: C Jan 23rd, 2005
Replies: 5
Views: 2,163
Posted By Chainsaw
As Dave says, you won't convince any legitemate system to allow:

free("ERROR");

the equivelent of which you are doing by returning a pointer to "ERROR".

It generally works to return NULL if...
Forum: C Jan 14th, 2005
Replies: 3
Views: 1,676
Posted By Chainsaw
And your question is.... ?

Please don't say "write this for me!"
Forum: C Jan 14th, 2005
Replies: 7
Views: 2,253
Posted By Chainsaw
I don't know what IA-64 and IA-32 refer to. Is that a particular hardware standard?

Typically segfaults of this type are because your CPU demands that shorts be aligned on short boundaries, longs...
Forum: C Jan 13th, 2005
Replies: 9
Views: 6,880
Posted By Chainsaw
You might investigate the std::map template, where you could do something like:

map<string, string> variableMap;

and then fill it in with commands like:

variableMap["CustomerName"] =...
Forum: C Jan 12th, 2005
Replies: 9
Views: 6,880
Posted By Chainsaw
Or since you only have three possabilities, could it be as simple as

if (stricmp( variable_name, "temperature" ) == 0)
<set temp>
else if (stricmp( variable_name, "pressure" ) == 0)
<set...
Forum: C Jan 12th, 2005
Replies: 2
Views: 5,259
Posted By Chainsaw
http://www.google.com/search?hl=en&q=%22space+complexity%22

71,000 answers there!
Forum: C Jan 11th, 2005
Replies: 5
Views: 1,889
Posted By Chainsaw
Code tags would help, yes. See the note about code tags at the top of the forum.

But, offhand, here's what I noticed:
1) I don't see you setting the id number of the node
2) You do a strcpy()...
Forum: C Jan 11th, 2005
Replies: 4
Views: 5,701
Posted By Chainsaw
If the data received is 2 bytes, why can't you use a switch?

#define SWITCH_DATA( L, R ) ((L << 8) | R)

switch (SWITCH_DATA( firstByte, secondByte ))

case SWITCH_DATA( 'A', 'B' ):
<do stuff...
Forum: C Jan 7th, 2005
Replies: 2
Views: 3,322
Posted By Chainsaw
fflush() is one of the standard C routines for file manipulation. It causes the currently pending data, if any, to be 'flushed' (written) to disk. When you call fwrite(), the data may not be...
Forum: C Jan 6th, 2005
Replies: 1
Views: 2,247
Posted By Chainsaw
There are generally two kinds of parameters to a function, those by VALUE and those by REFERENCE. A VALUE parameter is one where the variable's value (it's contents) are passed to the routine,...
Forum: C Dec 26th, 2004
Replies: 3
Views: 1,524
Posted By Chainsaw
That sounds great! Did you have a question, or something we should comment on?

Were you hoping someone has a program lying around that does this? Like, someone who took this class last year? ...
Forum: C Dec 20th, 2004
Replies: 2
Views: 3,207
Posted By Chainsaw
Like this?

virtual void **ReturnArrayOfPointers() = 0;

Replace void with the array of pointer's type (like int, float, MyRec, whatever)
Forum: C Dec 4th, 2004
Replies: 3
Views: 2,464
Posted By Chainsaw
you mean like:

1.2345
1.2344

is the same to 3 figures?

So, couldn't you say

int intX1 = (int)(x1 * figures);
Forum: C Nov 24th, 2004
Replies: 19
Views: 6,978
Posted By Chainsaw
Ok, here's another way to think about pointers.....

Imagine you are at a dog show and there's a row of dogs in front of you. The judge says he wants to see the dogs in order of size. Your job is...
Forum: C Nov 23rd, 2004
Replies: 7
Views: 7,027
Posted By Chainsaw
I'm no math major, but the running average idea is something like this:

can you add these as static members to BST? Static because you need this for the whole tree, not just for a single node:
...
Forum: C Nov 22nd, 2004
Replies: 7
Views: 7,027
Posted By Chainsaw
And, using statics and globals really undermines the meaning of a recursive function, in my humble opinion. It also makes the function non-thread-safe, which may be ok in this instance but isn't a...
Forum: C Nov 22nd, 2004
Replies: 7
Views: 7,027
Posted By Chainsaw
I suppose with floating point numbers you could keep a running average as you go, but why do this extra weirdness when you can get the total and total count recursively? Is it just because that's...
Forum: C Nov 21st, 2004
Replies: 5
Views: 4,266
Posted By Chainsaw
You didn't mention where this is, I can think of two valid places:

GLfloat colours[][3] =
{
{ 1.0, 1.1, 1.2 },
{ 1.3, 1.4, 1.5 },
<and on and on>
};

In this case, the declaration...
Forum: C Nov 21st, 2004
Replies: 19
Views: 6,978
Posted By Chainsaw
Right, you are confusing 'chars' with 'array of chars' and 'array of array of chars'. It would probably help yourself to describe what the variables are ("this is a char", "this is an array of...
Forum: C Nov 21st, 2004
Replies: 7
Views: 7,027
Posted By Chainsaw
How about something along these lines, assuming every node has a value 'myValue' and a left and right child pointer:

int BST::findTotal( int &nodesFound )
{
nodesFound++;
int total =...
Forum: C Nov 20th, 2004
Replies: 4
Views: 2,675
Posted By Chainsaw
It sounds like you changed

sprintf(files_to_open, "/usr/bin/ksh %s", filename);

to

sprintf(&files_to_open, "/usr/bin/ksh %s", filename);

because that would be a char**, not a...
Forum: C Nov 20th, 2004
Replies: 4
Views: 2,675
Posted By Chainsaw
files_to_open has no space reserved for it. You declared it as a char* but didn't 'new' it. So do one of these two things:

char* files_to_open = new char[ kMaxFileSize ]; // don't forget to...
Forum: C Nov 19th, 2004
Replies: 3
Views: 2,171
Posted By Chainsaw
If you were reading names from a file and wanted to make them prettier you could use strlwr() and the like, but here you are manufacturing totally random names in a loop, so you could do something...
Forum: C Nov 18th, 2004
Replies: 2
Views: 4,210
Posted By Chainsaw
inside the loop try:

searchptr=strstr(searchptr+1, line2);

You want to start each subsequent search at one char past where the last search stopped.

Oh, yeah, and move the printf INSIDE the...
Forum: C Nov 15th, 2004
Replies: 7
Views: 2,108
Posted By Chainsaw
Ususally it means you referenced a pointer that is NULL or uninitialized. In your case, 'sp' appears to be an uninitialized pointer.
Forum: C Nov 15th, 2004
Replies: 10
Views: 3,135
Posted By Chainsaw
For small simple loop variables, or very localized intermediate results, I may use single letter variables.

And, of course, for loops, the time-honored values of i,j,k,l left over from FORTRAN are...
Forum: C Nov 9th, 2004
Replies: 10
Views: 3,291
Posted By Chainsaw
The polling idea is something like:

while (BumpersOk())
{
if (!DecideWhatToDo()) break;
if (!BumpersOk()) break;
if (!DoWhatYouDecidedToDo()) break;
if (!BumpersOk()) break;
}
Forum: C Nov 9th, 2004
Replies: 10
Views: 3,291
Posted By Chainsaw
Well, if threads aren't supported by your IDE or the OS that is running on the robot, you're in a world of hurt. You could build your own thread management, but that is pretty advanced.

Is the...
Forum: C Nov 7th, 2004
Replies: 10
Views: 3,291
Posted By Chainsaw
Make a separate thread that monitors the bumper. When the bumper is activated, it calls some routine to immediately shut down the motors, or whatever.

Do you have to poll the bumper switches, or...
Forum: C Nov 5th, 2004
Replies: 9
Views: 2,774
Posted By Chainsaw
Your code tries to read 16 chars from the console, but you say you need to be reading from a file. As Naru points out, you can use fgets, or you can use fgetc() or something similar.

int count =...
Forum: C Nov 4th, 2004
Replies: 2
Views: 1,504
Posted By Chainsaw
Close, but you want to count the number of LINES, and the total number of BYTES you read. How about this pseudocode for the loop:

int ch; // fgetc returns an int, not a char
// skip the for...
Forum: C Oct 31st, 2004
Replies: 2
Views: 2,974
Posted By Chainsaw
Generally, a binary tree is a collection of nodes, each with one 'parent' and two 'children', a 'left' child and a 'right' child. In addition, there would be some data or payload.

But from there,...
Showing results 1 to 40 of 104

 


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

©2003 - 2009 DaniWeb® LLC