Salem 5,265 Posting Sage

> Can you give me an example.
What are you on about (or how helpless are you)
http://www.mega-nerd.com/libsndfile/command.html#SFC_CALC_SIGNAL_MAX
There - in large letters for anyone with eyes to see - the word "Example" followed by a snippet of code.

JasonHippy commented: My point exactly! +2
Salem 5,265 Posting Sage

> This one defective ball can be either heavy or light.
How much information are you really after?
- find the odd one (and not care about its mass)
- find the odd one AND know whether it is heavier or lighter than the rest

So far, the first answer is a special case in 2 steps (for 7+1).

Salem 5,265 Posting Sage

> Is the DVD version in 3D?
No, it's the same thickness as regular DVD's :icon_razz:

Salem 5,265 Posting Sage

-l traditionally assumes a lib prefix and a .a suffix.

Salem 5,265 Posting Sage

> g++ -LD:\Program Files\Lua\5.1\lib -oMacroLua.exe MainLuaTest.o
You told the linker where to look, with the -L option.

But you also need to say which library you want, with the -l option (that's lower case L).

If the library is liblua.a for example, you would add -llua to the command line.

Salem 5,265 Posting Sage

Can you post an example in context?

A single line "what's this do" means nothing.

Salem 5,265 Posting Sage

Compare with the code generated by the compiler?

gcc -S prog.c
will generate
prog.s

All that push/pop in the loop is expensive!

Salem 5,265 Posting Sage

Here is a function pointer tutorial
http://www.newty.de/fpt/fpt.html

> I have attached below a very simplified version of my actual code.
A simplified version that actually compiles would help.
Like what is fct() on line 55?

Sure, you have to leave a few lines commented out where the trouble is, but if we fix that, then it should work.

kvprajapati commented: Great link. +9
Salem 5,265 Posting Sage

Your default Node constructor makes sure it is empty (in a way the rest of your Node class will recognise).

Salem 5,265 Posting Sage

> I tried using ./configure to install it, but it didn't work.
Do you go to a doctor and just say "it hurts" and then expect a cure?

Or do you offer up some additional information which might actually help your doctor to figure out what is wrong with you.

In other words, post your install log and the error messages!

Salem 5,265 Posting Sage

These are functionally equivalent, if you want to get a grid out of storegrid back to the caller.

typedef struct grid Grid;

struct grid{
    char grid[MAX_ROW][MAX_COL];
}

void storeGrid1(Grid **result,int row, int col){
  Grid *mygrid;
  mygrid = malloc(sizeof(Grid));
  // more stuff
  *result = mygrid;
}

Grid *storeGrid2(int row, int col){
  Grid *mygrid;
  mygrid = malloc(sizeof(Grid));
  // more stuff
  return mygrid;
}

int main ( ) {
  Grid  *g1, *g2;
  storeGrid1( &g1, 3, 3 );
  g2 = storeGrid2( 3, 3 );
  free( g1 );
  free( g2 );
  return 0;
}

> store_grid->grid[rowNum - 1][colNum] = 'a';
This is an out of bound reference for the first row.

Salem 5,265 Posting Sage

Well &TBall::DrawBall; is just a pointer to a function.

To actually call it, you need say TBall::DrawBall()

Maybe even

TBall theBall;
// init code
theBall.DrawBall();
Salem 5,265 Posting Sage

Try Node *Node_array = new Node[5]; or Node *Node_array = new Node[someNumberOfNodesYouWant];

Salem 5,265 Posting Sage

> It reduces the likelihood of accidentally using an assignment statement (a = 1) instead of an equality statement (a == 1)
Or it increases the likelyhood of making a mistake when you have (var1 == var2), and no amount of rearranging the code will save you.

Plus, a lot of people find such code to be highly unreadable.

Further, operand swapping zealots also extend this to the relational operators as well (<, > etc), where there is absolutely no value in doing so. I've seen people introduce BUGS into working code because they made a mess of it.

Most modern compilers will diagnose use of = in an if statement right off the bat, without having to mess with the code at all. And this includes the important edge case where rearranging fails.

http://c-faq.com/style/revtest.html
It's from a time long ago when compilers only had error messages, and blindly generated code so long as it was syntactically correct.
If you're still using such a compiler, consider upgrading.

Salem 5,265 Posting Sage

Protect from who?

If you edit the files, you may end up with a copy in the swap file.

If you delete the file, the data will remain on disk until the space is re-used by the file system.

If you compile the file, then the pre-processor expanded copy of the source might be in the temp directory. Even if it's deleted, problem 2) remains.

Salem 5,265 Posting Sage

Because a sequence beginning with a letter would be indistinguishable from a regular identifier.

You could try it, and see if you get an 'undeclared identifier' error.

Salem 5,265 Posting Sage

Writing out all the representable floats would be do-able (with a bit of outside the box trickery).

Salem 5,265 Posting Sage

> for(int i=1;i<4;i++)
This doesn't initialise ALL the elements.

> bmpHeader.BitsPerPixel=24;
You've said the format is 3 bytes per pixel - so why are you writing 4?

Padding for 4 byte alignment (Could be a value other than zero)

You forgot to take into account this little detail.

Generally, you need to assemble a byte array yourself, then write that out.
Pointing at some struct is generally a bad approach, even when it seems to work.

Salem 5,265 Posting Sage

"(press any key to quit) A
(save before exit?) N
(are you sure?) Y"


For someone wearing one of HG's suggestions...
"127.0.0.2
<-- I live next door to this guy"


One for the ladies :icon_razz:
"Thread Bumps!"

Salem 5,265 Posting Sage

Sure - but what about the "1 second" bit of the problem?

Salem 5,265 Posting Sage

Why does ONESEC fall through to CLEARALL ?

Salem 5,265 Posting Sage

> Try searching for "final project" here. I'm sure you'll find plenty of results.
They already did that on google, which is why they're now here!

Besides, all that would prove is the terminal lazyness of all the "plzgimmeaproject" types which drive-by.

If they ever bother to return, it's only to state the goldilocks problem once more (too hard, too easy).

Just lock the threads and delete the bumps to this kind of post - nobody will miss a thing as a result.

Salem 5,265 Posting Sage

How long does it take to clear the listview control, then repopulate it with 1000 entries?

Sorting the original data without all the excess baggage of the control might just be more efficient.

Also, are display updates turned off by the control when it does the sorting? Or is it busy repainting things as it goes?

Just some guesses...

Salem 5,265 Posting Sage

Well if you were using a real OS with a decent set of command line tools, then I would suggest http://www.manpagez.com/man/1/cut/

But since you seem (from your other posts) to be using an OS where all you can do is attempt to create fine art with wax crayons, then I dunno.
Download ActiveState perl would be one suggestion.

The only command in windows console that doesn't get really messy in a hurry is 'exit' ;)

Salem 5,265 Posting Sage

Your code could potentially generate from
0 0
to
9 9

That's 100 possibly combinations right?

So your "I've seen this before" test needs that much space to remember what has gone before.

Salem 5,265 Posting Sage
for ( i = 0 ; line[i] != '\0' ; i++ ) {
  if ( line[i] .... 
}

Parsing is simply walking along the line one character at a time, then making decisions based on what you've seen already and what is immediately in front of you.

Some parsers "look ahead", but I don't see that being necessary in this case. Once you've got past the name, it seems pretty easy going.

Salem 5,265 Posting Sage

> err = SVS_TCP_send(activeSck, 921600,(char*)rgbImg.ucBmpData, &sent);
What do you get returned in sent?
Or err for that matter.
Is your buffer really 900K long?

> iRcvd=m_sConnectSocket.Receive(&imgBuf[tot],len-tot,0);
is imgBuf also 900K long?

What about the array you're copying it into?

Is it just a size problem, like it works for much smaller sizes (say 1K)?
If so, is there a cut-off where it starts going wrong?

Salem 5,265 Posting Sage

What about just 'diff' ?

Or 'fc' if you're on the dark side.

Salem 5,265 Posting Sage

This loops, reading a whole line, one line at a time.

char line[200];
while ( infile.get(line,sizeof(line)) ) {
}

The problem is, your names have a variable number of spaces. So you can't just use one of the standard file input methods to do the parsing for you.

The best you can do is read the whole line in, then work your way through it to identify each of the fields.

Salem 5,265 Posting Sage

I answered it from the point of view of "a homework kiddo doing nothing at all except waiting to be spoon-fed an answer in 5 seconds" ;)

Salem 5,265 Posting Sage

You go and study the fstream methods and string methods and figure out another way of solving the problem.

- You had an idea
- You tried it - it didn't work (everybody gets here at some point)
- then you try to understand WHY your idea didn't work (now you're here)

So go back to the beginning and think up a fresh idea and try that.
Only this time, you know a bit more about the problem so hopefully you'll make a better attempt.

Salem 5,265 Posting Sage

> user entered word and program printing backwards word. This is all that need for me
Do you want to learn?

Or are you just hoping to get a spoon-fed answer (congrats, you've already won).

Because if you've no interest at all in learning, then just tell us and we will not try to help you at all.
Then you'll just be at the mercy of the drive-by spoon-feeders.

Salem 5,265 Posting Sage

> #! /usr/bin/perl
First begin with

#! /usr/bin/perl -w
use strict;

Then you'll get warning about your mis-spelling

$exp = <STDIN>;
chop $ex;   # NOT exp !?

Paying attention to what you post as well would help. It looks like two attempts at copy/paste from a screen dump.

Salem 5,265 Posting Sage

Like I said, reading too much data with the get()

while (!infile.eof())
  {
    infile.get(name, MAX_NAME_LENGTH)>>ws;
    cout << "Debug:==" << name << "==\n";
    infile >> years>>ws;
    infile.get(department, MAX_DEPT_LENGTH)>>ws;
    infile >> ytdpay;
    
    if ( infile.fail() ) {
      cout << "It's dead Jim!\n";
      break;
    }
  }

Now I get

$ g++ foo.cpp
$ ./a.out 
Debug:==Samuel Spade 10 Auto==
It's dead Jim!

Yes I got a bunch of
Debug:====
Debug:====
until I stopped it scrolling madly off the screen.

Where your file is

$ head PJ811_personnel.txt
Samuel Spade 10 Automotive 22020.45
Annie Smith-Johnston 4 Appliances 25123.96

Having munched 20 characters, the stream has the unlikely prospect of converting "motive" into an integer. This of course fails, and this sets the fail() to true (but leaves the eof() false).

So it enters an infinite loop of failing to do any more conversions because the stream is now in an error state.

Salem 5,265 Posting Sage

Read this, and the other intro threads.
http://www.daniweb.com/forums/announcement125-2.html

> i write "hello" and program write "olleh".
Try.
- printing hello from a string already initialised in your program
- printing a string as the user types is (letter for letter)
- printing a whole string as entered by the user
- as step 3, but backwards.

Where exactly are you stuck on this process?

If nothing else, doing the simpler steps first will give you something to develop with.

Salem 5,265 Posting Sage

I remember seeing such things when trying to compile C code with a C++ compiler.

Though to be honest, there are better choices for getting a GCC compiler on windows nowadays (http://www.codeblocks.org/)

Salem 5,265 Posting Sage

http://www.cplusplus.com/reference/iostream/istream/get/
Well your get methods always seem to consume 'n' characters regardless of the actual length of the field involved.

infile.get(name, MAX_NAME_LENGTH)>>ws;
cout << "Debug:Name==" << name << "==\n";

Does this do what you expect?

Salem 5,265 Posting Sage

Seems like this to me
http://en.wikipedia.org/wiki/Race_condition

> 5. int result = _stat( strDestFile, &buf ) where strDestFile is the file from step #2
> 6. I get buf.st_size as 0
Ah, but what was in result?

Salem 5,265 Posting Sage

As in
if ( k == 0 ) return
kinda thing?

Find some examples of the cmp instruction.

Salem 5,265 Posting Sage

AFAIK, you can only wait for each child exactly once.

The process 'stub' the OS keeps around between the end of the child to hold the information you get with 'wait' calls will disappear as soon as that information is delivered to you.

Salem 5,265 Posting Sage

Converting a string to an int (without functions) is no harder than working out the length of the string (without functions).

In fact, you can pretty much cover it with the same code.

Salem 5,265 Posting Sage

Sodabread's sig is pretty good (and concise enough for t-shirts)

Salem 5,265 Posting Sage

So what does your input file look like?

Salem 5,265 Posting Sage

If each image has a bounding rectangle, then that could be a pretty easy test.
http://www.gamedev.net/reference/articles/article735.asp

Depends how accurate you want to be.

Salem 5,265 Posting Sage

Start with strlen(), before you convert it.

Salem 5,265 Posting Sage

> I currently have working code to solve a single first order differential equation using a predictor-corrector.
Did YOU write it?

I mean, if you did, then you should be able to at least take a swing at trying to write the new one yourself as well.

Otherwise it looks like another helpless "Hey, I need an orange - if it's of any use to you, I found this lemon".

Salem 5,265 Posting Sage

> while(input[k]=getchar() != '\n')
Precedence

You wrote
while(input[k]=(getchar() != '\n'))
which just assigns boolean 0 or 1 based on the logical test.

You want
while( (input[k]=getchar()) != '\n')
which assigns the character read to the array, then compares it.

Salem 5,265 Posting Sage

> #include <iostream>;
Includes are not statements - remove the trailing ;

Also, which is the real line 83?
This code looks edited compared to what you compiled.

> cout << " The inventory total is " << itemNUM <<" items.\n";
itemNum isn't declared anywhere.
But that's on line 128.

Salem 5,265 Posting Sage

http://home.comcast.net/~fbui/intel_l.html#loop
LOOP - Decrement CX and Loop if CX Not Zero

0 - 1 is a large number, which is plenty enough to wash away all the bits.

Detect 0 BEFORE entering the loop.

Salem 5,265 Posting Sage

Line 61 is outside your loop.