Salem 5,265 Posting Sage

> Career opportunities
Hard to pin down now, nevermind in several years time when you graduate.

> average pay of specific computer science fields
Again, depends where you are and what's flavour of the month when you need to start looking. What's hot today could be well out of date by the time you get to it.
Besides, you should go for what interests you, not what pays a few K more. Once your basic needs are satisfied, then job satisfaction counts for a hell of a lot.

> common programming languages used for each field
Yet another moving feast.
Find a college which at least has a course on software engineering. A short course in "language X" ain't worth squat IMO. It just churns out "hello world" programmers by the 1000's. The real skill is knowing what to do when confronted by a task which will take 10's of thousands of lines of code (and up into the millions). If you don't know how to solve that kind of task, then it really doesn't matter how well you can recite code fragments.
The thing of it is, when you get to those kinds of programs, there is a lot of work which isn't actually programming.

Also, the actual detail of your degree (and the final year project you did) only matters for your first job. After that, your degree is just a tick box.
"Do you have a degree, …

darkagn commented: Good advice all of it :) +3
Salem 5,265 Posting Sage

> local variable 'legajo' used without having been initialized
Pay attention to these as well!

Salem 5,265 Posting Sage

Do you have other crap in your .bashrc (for example)?

Do you get the same crap if you have a really simple command like say "echo hello"?

Does for infofile in *.info ; do grep -q 'PID: 10631$' ${infofile} ; if [ $? = 0 ]; then grep 'Trace File:' ${infofile} | awk '{ print $3 }' ; grep 'Trace Signal:' ${infofile} | awk '{ print $3 }' ; fi; done | od -Ax -t x1z show only the characters you expect, and nothing else?

Does sh -c echo hello | od -Ax -t x1z show the junk characters?

If so, then I'd say it was something in your initial shell startup which is just printing something.

If you do find it, then either remove it, or put it inside something like

if [ "$PS1" != "" ]; then
  # do interactive shell specific stuff here
fi
Salem 5,265 Posting Sage

Yeah, that's pretty much wrong. You can't look at the data to determine what happened.

char tempBuffer[100];
int error = recv( sock, tempBuffer, sizeof(tempBuffer)-1, 0 );
if ( error > 0 ) {
  // error is the number of bytes received.
  tempBuffer[error] = '\0';  // we allowed room for this with the -1 in the recv
} else if ( error == 0 ) {
  // connection closed
} else {
  // an error
}

OK, the next problem you have to solve (assuming this is a TCP connection) is fragmentation.
Say for example, you send (in one call)
"hello world".
Now it's entirely possible that at the recv end, you'll get "hello wo" and then sometime later, "rld". It's your job to reassemble the message into it's proper form. One way would be to frame your messages with say a \n

It gets worse. Fragmentation can also happen on the send() call as well. You need to look at that return result as well to make sure that you sent everything. If not, you need to call send() again with the remainder of the buffer (until it's all gone).

Salem 5,265 Posting Sage

The "used without being initialised" refers to your line 20.
You don't set it to anything, then you pass it to a function.
Answer: initialise it.

> //this for isnt countin
Your while loop is doing the counting - check line 51.
You have two loops, so I guess it goes round one more time than you expect.

Salem 5,265 Posting Sage

> The largest problem is that winsock appears to be appending data to the end of the buffer
My guess is that you're assuming recv() appends a \0 (it doesn't), and you're also not paying close enough attention to the return result of recv() either.

> When I used to program Visual Basic, winsock worked perfectly, but not so with C++.
Ah, that explains everything. The API has been mucked about with "for your convenience" rather than adhering to any standard.

Salem 5,265 Posting Sage
Salem 5,265 Posting Sage

> that will constantly read a record from a database.
Once a second?
Or maybe once a minute?

Make one (or several, for redundancy) the master which is responsible for reading the DB. When it changes, the master sends out a "UDP Broadcast" packet (or several, for redundancy) which basically says "do it now!".

All the other clients will just be waiting for messages to arrive, and performing the action when the message arrives.

Prabakar commented: Perfect Solution:) +1
Salem 5,265 Posting Sage

> but I've been having several problems with winsock.
Such as?

If it's because your programs are crashing, or have odd behaviour?
Then I'm afraid that's all down to bugs in your code. Changing libraries won't solve anything.


Or is there some aspect of network functionality you deperately need?
In which case, you should state your requirements.

Salem 5,265 Posting Sage

What else is in your code?
Did you define those symbols yourself?

Post a minimal complete program which demonstrates the problem.

Salem 5,265 Posting Sage

> 1B 5B 33 67
= ESCAPE [ 3 g
> 1B 48
= ESCAPE H
http://clusty.com/search?query=escape+sequence+ANSI&sourceid=Mozilla-search
And an ASCII table if you can't do that stuff in your head yet.

I'm guessing your "cd /home/user" is an alias for something which outputs a bunch of escape sequences and then changes directory.
All fine and dandy if you're using a terminal, but utter crap if it's in a pipeline.

You're going to be a lot better off putting chdir( "/home/user" ); in your C code.

I'm somewhat surprised that such a complicated shell command passed to popen actually does something reasonable.

Salem 5,265 Posting Sage

Well the last line would (probably) launch Excel on a machine where Excel was installed, and all the file associations were set up correctly.

Other than that, your analysis is good.

OmniX commented: Thanks for the support! +1
Salem 5,265 Posting Sage

Sheesh - 200 posts, and the indentation is still crap.

Your super IDE may be able to make sense of your crazy mix of spaces and tabs, but most everything else will (sooner or later) make a complete pig's ear of it.

Do everyone a favour and turn OFF tabs, and turn on smart indenting with spaces. It won't cost you any extra keystrokes, and it'll make for a much better experience all round.

Here, indented with spaces only

bool list::del(Contributor Del)
{
    Contributor infoIn=Del;     // Contributor is the object, 
                                // infoIn is the specific object
    
    node *pprev= plist;         // plist is the beginning of the list, 
                                // ptrav is what some
    node *ptrav= plist;         // would call "temp" or "head",
                                // and pprev is the "tail"

    if (empty())                // checking for empty list
    {
        cout<<"The list is empty "<<endl;    
    }

    if (pprev==ptrav)           //to delete from beginning of list
    {
        
        plist = ptrav->next;    //sends plist to next node
        delete ptrav;           //delete Node
    }
    
    while((ptrav!=NULL) && (ptrav->infoIn!=Del))
    {
        pprev= ptrav;
        ptrav= ptrav->next;
    }                           //These functions should search for the

    // proper item to delete, and delete it
    if (pprev==ptrav) 
        return false;
    else
    if(pprev==NULL)
    { 
        plist= plist->next;
        delete ptrav;            
    }
    else
    {
        pprev->next =ptrav->next;
        delete ptrav;
    }

    return true;
}

Rejoice in the consistency of formatting no matter what editor or forum you post it on.

Salem 5,265 Posting Sage

Don't forget the change of units, otherwise you'll be hibernating rather than sleeping ;)

iamthwee commented: Amen sleep(3000) ain't the same in windows. +17
Salem 5,265 Posting Sage

> hThread=creatThread( Null, 0, ThreadFunc, Null, 0, &ID);
Yeah, there's a problem.
As soon as Create() returns, you've got a danging pointer to a local variable which no longer exists.

If you want to pass parameters to threads, the safest way is to allocate some memory, fill in the details you want to communicate, then pass that pointer (which will be persistent and unique) to the thread. The thread then frees that memory when it's done with it.

> and i go through the code with F11 it goes to header files for allocating the
> memory and suddenly drops out.
Any prior abuse of allocated memory could do this as well. If you've already trashed the pool (maybe even some time ago), then failure at any time is always an option.
Cause and effect (when it comes to dynamic memory in particular) are seldom in the same place. You need to start looking for a cause, rather than staring at the effect.

Salem 5,265 Posting Sage

> PUSH 6(BP) ! here i'm putting romfile on the stack again
It's the way a compiler would do it.

> another solution would be to have a register (BX maybe?)
Also a possible way, for example __fastcall

Whether you push all the params, or pass a few in registers, I think you'd still declare the function in the same way. readfile(char *file) Tells you the interface, not the implementation.

Adopting a consistent approach which works would be more important than over-optimising every single case.

Salem 5,265 Posting Sage

Your results are time_t's (or should be) struct tm * timeinfo = localtime(&res[i][1]);

Salem 5,265 Posting Sage

http://www.opengroup.org/onlinepubs/009695399/functions/localtime.html
Use localtime() or gmtime() as appropriate to turn a "time_t" into a "struct tm".
Use mktime() to go the other way
Use strftime() to format bits of a struct tm

Salem 5,265 Posting Sage

Well the next step would be to go read up on how the sieve actually works.
Because your code looks nothing like it.

For a start, the outer loop should stop at the square root of 300.

Salem 5,265 Posting Sage

> for (i = 0; i<=300; i++)
Arrays run from 0 to N-1
So it's < 300, not <= 300

Salem 5,265 Posting Sage

That you're stepping off the ends of your arrays would be one problem.

Salem 5,265 Posting Sage

> When the debug's DLL is used, the application does not crash when exit (running on Vista).
> However, it crashes upon exit when the release's DLL is used instead (also running on Vista).
That means there are bugs in your code for sure.
Unless you post some code, then you're on your own. Try running the release code in the debugger. It should at least give you some idea of where the problem is.

> The application works fine with both the debug's and release's DLL running on XP.
That just makes you lucky, not good.

Your debugging effort stopped when the program stopped crashing, but that didn't mean the program was bug-free.


If you want more phrases, then try these.
"Testing can only be used to show the presense of functionality, not the absense of bugs."
"Testing is like pouring cold water into a chocolate teapot and saying that it works."

Salem 5,265 Posting Sage

You basically need a copy constructor as well.
http://en.wikipedia.org/wiki/Copy_constructor

With one of these, the compiler should generate the code to clean up the temporary, rather than just dropping all the bits on the floor.

Salem 5,265 Posting Sage

> {146} normal block at 0x003363A0, 8 bytes long.
> Data: < c3 > E8 63 33 00 00 00 00 00
If this number is anything like consistent (it should be in such a small program), then you can do one of two things.

1. Right at the start of main, do this _CrtSetBreakAlloc( 146 ); 2. In the debugger, open a watch window, then examine the symbol _crtBreakAlloc .
Set that value to 146

Then run the code.
When that block is about to be allocated, you'll drop into the debugger. From there, you can step through the code to work out why you don't free that particular block.

Work your way through the list, starting with the low numbered blocks first.
- they're the ones most likely to have consistent numbers
- if they are containers, then freeing those will probably fix a lot of later allocations as well.

Salem 5,265 Posting Sage

0xfeeefeee is one of the patterns filled in memory after it has been freed.
http://www.nobugs.org/developer/win32/debug_crt_heap.html

Salem 5,265 Posting Sage

You haven't been trying to delete books anywhere else have you?
Deleting the same book twice is a sure recipe for disaster.

I see your addBook() returns a pointer to a book (why?). What else are you doing with that book pointer?

If you need to remove a book, then you need another member function, say delBook(), which removes the book from the set, and then deletes it.

Undertech commented: You were right, although it wasn't immediately obvious! +1
Salem 5,265 Posting Sage

Why is it so hard to tell people about the best way of doing it, rather than some old hack which they'll have to unlearn sooner or later?

It's not like there's a massive difference in line count (or anything) between the two.

stringstream (the basics of it) takes no more explaining that explaining atoi would. Probably less, if you exclude all the caveats.

Aia commented: Logic might get us not very far in this one. +9
Salem 5,265 Posting Sage

How about doing something like

string msg = "This server has been contacted time";
msg += hello;
msg += "\n";

Then later, when you absolutely need a char array to call send(), do this send( fd, msg.c_str(), msg.length(), 0 );

Salem 5,265 Posting Sage

Old, yes. Good, not a chance!
It can't even detect integer overflow.

Salem 5,265 Posting Sage

Yeah, did you miss all the "read first" bits which explain code tags?

First thing, add

if ( sizeof(_bpb) != 512 ) {
  cout << "bpb wrong size";
} else {
  // carry on with your code to read and memcpy
}

Notice how this short snippet is formatted!

Salem 5,265 Posting Sage

Well that really depends on what type _bpb is.
If it's anything other than say unsigned char _bpb[512] then you're likely doing something wrong.

Post some code, in particular, some declarations of the variables involved.

Salem 5,265 Posting Sage

http://mobilephonedevelopment.com/archives/492
Perhaps a good look around that site in general will be of some use to you.

You've already biased your answer by posting in the C++ forum.

> Actually I decided to do in c++ but some of my friends say it is not a good idea to do it!
And is their level of expertese on the subject any better than yours?
Or is it just more smoke from their own naive biased opinion?

The first question is, what sort of application?
If it's UI-centric and doesn't need lots of performance, then try Java.

Salem 5,265 Posting Sage

Solved?

inFile.get(buffer,length);
length is the length of the file, but get only reads a single line ?

0xCD is what the Microsoft run-time fills up allocated memory with as you allocate it, so that you can easily spot use of uninitialised data.
Just filling it with memset seems like sweeping the problem under the carpet, not a solution.

Salem 5,265 Posting Sage

> I am trying to create a simple C program that uses HandBrake (video converter).
Is this a deliberate exercise in using C, or are you really just after a quick way of solving the problem, and you thought C might be the best answer?

Because if you're willing to entertain alternatives, then consider using the shell. Especially if all you're doing in your C program is a bit of string manipulation then calling system().

#!/bin/bash
echo -n "What filename > "
read filename
HandBrakeCLI -i /dev/hdc -o /root/$filename -b 1024 -B 128 -R 48 -E faac -f mp4 -w 368 -l 208 -m

Note: the last line is all one line, ignore the forum line wrapping in code tags.

Salem 5,265 Posting Sage

char [B]*[/B]replace(char string[100]) and return(string);

Salem 5,265 Posting Sage

Tested what?
If you made changes, and it doesn't work, then post your updated code.

Salem 5,265 Posting Sage

> string != '\0'
Compare with string != '\0'

Also, make the function return a char*, and return string.
That is, if you want to print the result with %s

Salem 5,265 Posting Sage

<kosh>YES</kosh>

Salem 5,265 Posting Sage

Well you probably shouldn't be modifying first, just to print it.

Salem 5,265 Posting Sage

To pass an array, you just need the name (no [ ] needed in the call)

Also, for loops should generally be < n ( and not <= n )
Yours runs off the end of the array.

Also, why not just say int a[10]; rather than initialising it with 10 elements which you're just going to overwrite anyway.

Don't forget, void main is wrong. Main returns int.

Salem 5,265 Posting Sage

http://www.theholidayspot.com/friendship/history.htm
But like anything else, it's starting to look like just another merchandising opportunity to make up for the slow period between the previous splurge and the next splurge.

"friendship day origin" is your search term of the day.

Salem 5,265 Posting Sage

You can't tell how many arguments have been passed to a varargs function, you have to tell it how many there are. There are several ways of conveying the effective argument count.

printf( const char *format, ... );
printf( "The min is %d, the max is %d\n", min, max );

printf 'knows' the number of arguments from counting the conversion formats.

execl(const char *path, const char *arg, ...);
execl( "/bin/ls", "/bin/ls", "-l", (const char *)NULL );

execl 'knows' the number of arguments by counting through them until a NULL pointer is found.

Besides, I don't think the varargs thing is particularly well defined for a non-POD type such as std::string.

Salem 5,265 Posting Sage

> If the compiler replaces const at compile time, then the statement int &I = 5 ; is completely wrong.
The integer storage location called i will get updated through the reference, ignoring all the const'ness which goes with it.

It's just that the compiler (which knows the value, and sees the const), doesn't see your incorrect code and just does cout << 5

It you looked hard enough with a debugger, you might see this actually happening.

Salem 5,265 Posting Sage

> I just don't understand whats happening. This code won't compile in any decent compiler.
So ask your tutor why they're teaching you crap.

> 2) if 'I' is just the reference of 'i' then how come a memory location store 2 values 5 & 10.
It doesn't.
The cout statement probably looks more like cout << endl << 5 << " " << I ; Being const, the compiler is free to perform a value substitution at compile time. In that respect, simple consts in C++ resemble #defines in C.

As you say, any decent compiler would throw out all those "loss of const" errors.

Salem 5,265 Posting Sage

Interesting that there's some #define renaming going on.

You could try creating a very simple source file which includes the QT headers in question.
Then compile it with the -E switch, which just runs the code through the pre-processor.

What you should get is a very large .i file which contains the code AFTER the pre-processor has done all it's stuff to the file. Comparing the results between systems may shed some light on what's actually going on.

Unlike your google attempt, searching for QXmlStreamWriter finds lots of stuff.

Also look for Q_XMLSTREAM_RENAME_SYMBOLS in say a config.h file. It could be an install problem which has mis-configured one of the systems.

Salem 5,265 Posting Sage

What version(s) of QT are on the machines which work?

Why do the same directories repeat over and over in the compiler command line?

If you do a search of /usr/local/Trolltech/Qt-4.4.0/include, do any of those files contain QCoreXmlStreamWriter?
If they do, check to see if such references are inside #ifdef ... #endif conditional switches. If they are, you need those switches on the command line.

Salem 5,265 Posting Sage

A very long and detailed explanation.
http://docs.sun.com/source/806-3568/ncg_goldberg.html

Salem 5,265 Posting Sage

It would help if you used code tags.
I mean, you almost made it, but you still fell short.
Consider using the "review post" feature to make sure what you think you're getting is what you're actually going to get.

Salem 5,265 Posting Sage

> But they never get back later.
Yeah, agencies are like that, even for pros.

Unless you're exactly what they're looking for, you're just padding for their database. The only way to get them to do stuff for you (it seems) is to keep calling them to the point they find you somewhere just to shut you up :)

> I am currently located in UK!
I think a lot of places are looking to either cut back, or put a freeze on recruitment at the moment. It's going to be pretty tough for a while it would seem.

Have your other class-mates found work yet? If so, can then offer any tips?
What about your college, do they have a careers advice centre as well for recent graduates?

Salem 5,265 Posting Sage

Of course the real answer would be to use another std::string which is totally safe, as opposed to some non-portable API which is only safe so long as the programmer knows what they're doing.