Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Somebody forgot to read the Forum Rules as requested multiple times upon signing up.

Naw -- he just simply ignored them.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Browse around MinGW.org -- the Windows port of the GNU compiler. If you also want a nice IDE then download Code::Blocks, which also supplies MinGW compiler tools.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1) Depends on how quickly you learn. When I started I had nothing more than a book and an old Radio Shack computer with *nix-like os. I learned enough in about a month to get my first programming intro job with Account Temps (temporary employment agency). But that was mid 1980s and times have changed a lot since then.

>>Based on the summary provided in the second link, how much of the language does the book cover?
It's a beginner's guide so it only covers the very basics of the language. There is a lot that is probably not covered, such as containers and algorithms.

2. That's an excellent compiler and IDE, and its all that you need to get you started learning c++. Code::Blocks with MinGW is also excellent. As for books, all you need at first is an Intro to C++ book, see the Read Me threads at the top of this c++ forum for other book recommendations.

3. Old c++ will NOT become obsolete. The new standard will just add to the existing c++ standard. Once the new standard is released it will be several years before it is implemented by compilers. Some compilers still have not implemented everything in the current c++ standard. Microsoft VC++ 6.0 compiler is notorious for its lack of adherence to c++ standards.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Those are standard C++ libraries and implementation is nearly identical in all c++ compliant compilers. Unless you can provide us a specific instance where the two implementations are significantly different then your concern is unfounded. If you use Code::Blocks on both os then there will be no difference in how the standard libraries are implemented. I understand that some software houses only use Microsoft compilers, but that has to change when opting for cross-platform programs. And if you don't change then you will probably never get the project off the ground, or sit around waiting for several years until some miracle happens like Microsoft porting Visual Studio to *nix.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

@crarn: IMO your best solution would be to use Code::Blocks/MinGW on both MS-Windows and Ubantu. I like Microsoft compilers a lot too, but it isn't cross-platform to *nix. OpenGL would be the engine you need, not DirectX. It seems to me that you need to be more open minded and use the tools that produce the end-result you want instead of attempting to force the end result to meed the tools that you like.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Notepad does not know how to read binary files, so any attempt to make Notepad read binary data will fail. The only way to read binary data is either (1) write your own program to read it then display the data, or (2) use a hex/ascii editor which will display each byte of the file in both hex and ascii.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The return type is the same type as what the function returns. Those that return nothing are declared void function(); . If the function returns an integer then declare it as int function(); That shouldn't be all that hard to figure out -- just look at the return statement in the function.

lines 5-10 are in the correct place, all you have to do is add the return type to those function prototypes.

lines 13 and 14: that is calling function menu() twice. Delete the function call on line 13 and make line 14 look like the function call that's on line 13.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

didn't you read this. It was the second google link hit

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

which function do you mean? If you mean lines 6-10 then the those functions must be declared to return something, such as int function() or void something() . Default return values are not permitted in c++.

line 153: that should be () at the end because its calling a function. However, that aside, the line is making a recursive call because its calling itself, and that will crash your program because there is nothing in that function to stop the recursion.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Where can I download it?
Where can you download what?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Qns: 1st task: Can advise whether my code is ok?
Compile and run it to find out for yourself. But I faile to see how that's useful to your stated problem. The problem you posted does not ask you to write numbers to the output file.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

why are you trying to load a Microsoft DLL? The os will do it when your program starts.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The template was not working when the value of the item to be added is less than the value of the first item in the list. I corrected it like this:

template<typename T>
void sortlist<typename T>::add(typename T dataToAdd) {
	// if list is empty
    if(bottom == NULL) {
		bottom = new node;
		bottom->data = dataToAdd;
		bottom->next = NULL;
	}
	
	// iterate shall we?
	else {
		node* iter = bottom;	

		while((iter->data < dataToAdd) && (iter->next != NULL)) {
			iter = iter->next;	
		}
		node* newdata = new node;
		newdata->data = dataToAdd;
        if( iter == bottom)
        {
            newdata->next = bottom;
            bottom = newdata;
        }
        else
        {
		    newdata->next = iter->next;
		    iter->next = newdata;	
        }
    }
}

The second problem is printall() did not work correctly because it stopped before the last item in the list was printed. I don't like everything on one line as you had it because it makes it nearly impossible to step through the code with the debugger.

void printall() 
        
        { 
            for(node* x = bottom; x != NULL; x = x->next) 
            { 
                std::cout <<x->data<<"\n";
            } 
        }

[edit] Oops! what^^^ said too :) [/edit]

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The operating system populates argv[0] -- you don't have to do anything. When you type an argument on the command line it becomes argv[1], not argv[0].

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Is GetPlayerX() and GetOldPlayerX() two methods of the same c++ class? If yes then you could just store the position as a member of that class. If not then use a global (ugg!) variable.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
  1. Don't clear the screen because there may be information on the screen that people want to see. But you could use something like system("cls") or write your own cls() function using os api calls.
  2. namespace is just an umbrella used to keep symbol names from colliding with each other. It just groups together names/classes/structures/objects.
  3. getch() has nothing to do with the how to declare main(). main should never be declared as void because it always returns an integer whether you tell it to or not. Even if you omit the return statement main() will return an integer anyhow.
  4. Yes -- the syntax for a structure has never changed from day one when K&R was written.
  5. c++ does not require an explicit return statement -- main() defaults to 0 if you don't tell it to return something else.
  6. You can use them all except iostream.h, iomanip.h -- all you have to do is omit the extension on those two leaving <iostream> and <iomanip>.
  7. Put a 'c' in front of those names, such as <cmath> and <cctype>. The only difference is the compiler will put them under std namespace.
Salem commented: Nice +18
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Hi,

How do we read and write a byte array to a XML file in C++.

Its very complex to do in c++ -- a lot simpler in VBA. But read these articles.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The . operator tells the shell to look in the current directory for the program. Without the dot the shell searches all the directories listed in your PATH environment variable for the program and executes the first one found.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't use a mac but I know that wc file1 file2 works on *nix and MS-Windows. When you say "it doesn't work" what exactly do you mean. More than likely the problem is your program, not the os.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Is that supposed to duplicate the functionality of win32 api function LoadProcess() ? If yes, then why bother? What makes you think you can do it faster or better than the Microsoft experts?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That's a famous behavior of MFCs Close button -- the Close button is activated when the Enter key is pressed. One way to fix that is to catch the WM_CLOSE event and ignore it, but then you might not be able to close the program at all.

Another way is to catch the return key in OnTranslateMessage(). This is for CDialog, but you can do the same thing in any type of MFC program.

BOOL CTestmfcDlg::PreTranslateMessage(MSG* pMsg) 
{
	if( pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN )
	{
		return FALSE;
	}
	return CDialog::PreTranslateMessage(pMsg);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I am using the real version of google so i don't need any site of this kind.

That site is used to give a sarcastic answer to other people who could have used google to get quick answers to their question instead of posting the question here. If you don't help other people here then you would probably not use that site.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That's only a very small part of debugging facilities. With Microsoft all you have to do is double-click an error message and the cursor will appear on the line that caused the error. You were probably doing it the hard way.

There is a great deal more to debugging then just finding lines that contain errors.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

How many solved threads to you attribute to that?

I have no idea. Some people probably just ignore it, others get pissed off, still others learn from it (maybe they don't know about google???)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I prefer VC++ 2008 Express (or any other edition) because of its superior debugging tools. I have yet to see another non-Microsoft IDE that matches the debugging features and ease of use that VC++ 2008 has. The remaining features of that IDE are more eyewash than anything else and have been matched by other IDEs such as Code::Blocks.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 22: when is that file stream ever opened? Its a bad idea to make fstream an object of a class. Just declare it in the functions that need it, open it, use it, then close it when the function ends.

lin33: void main -- main NEVER EVER returns void. There are only two acceptable ways to declare main

int main()
{
{

int main(int argc, char* argv[])
{
}

Any other way is non-standard and could cause confusion with other programs.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Are you talking about the properties menu shown when you right-click a file in Windows Explorer? It will probably depend on the version of MS-Windows you are running. I am running Windows 7 and do not see a Category property. Attached is a picture of what I see. (As you can see there is no Summary tab).

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I've been using that for quite some time.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I think the question should have been
How Old Is Our Universe Right Now?

Do you imply there could be more than one universe? If our universe were just one atom in a cup of water, there could be an infinite cups of water.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>the one I like is that the anti-particles behave like regular particles traveling backwards in time.
How would they know the particles time travel?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

... when a computer with 64K memory was stored on three floors of a concrete building with millions of huge vacuum tubes.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It just doesn't make much sense to give a chicken elaborate rights and then eat it.

My thought about animal rights is not to treat them as humans, but to treat and/or kill them humanly -- animal rights does not prohibit slaughtering chickens for food, but rather raising them so that they are not always in pain, starving, living in swallow, etc. I read a report not long ago about some sick cows that were taken to the slaughter house, some could only crawl in because they were so ill and in pain. I've seen news reports on TV about horse farms where the horses were without food and water, they were so skinny that we could see the outline of all their bones. And we see similar reports about a dog breeder. These are the kind of things that need to be stopped.

As for clones -- IMO a human clone should be treated just like any other human. How would we know that someone was a clone ? Does a clone wear a big C on his/her forehead, similar to the H (for hologram) that Rimmer has on the sitcom Red Dwarf? When you pinch a clone does he not cry? When you tickle a clone does he not laugh? When you cut a clone does he not bleed ? Does he not have fingerprints, or finger nails that grow, or hair that grows?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I'm not familiar with QNX so I can not answer your specific question.

If you want to port a MS-Windows program to an *nix-like os then you might as well use a cross-platform library, like wxWindows, wxWidgets or QT. Don't try to port specific MFC functions or classes, but just the functionality of your program. You will probably wind up rewriting parts of the program, but isn't that what you are doing now?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

CObList is a linked list of CObject class objects (or derived from CObject). CList is a linked list (template) of any c++ class. If you want to know specific difference then look them up (google) on MSDN.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1) name is an uninitialized pointer. You have to allocate memory for it before it can be used as an input string (line 14). Just declare name as a character array instead of a pointer, such as char name[80]; line 11: There is no reason to make that variable a pointer since all you want is 10 floats. Just declare it as an array float array[10]; line 12: You can just delete this line if you make that variable an array of floats as above. In c++ programs you should use the new operator instead of malloc() or calloc().

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Read through Microsoft's Scribble Tutorial -- it is something similar to MS-Paint and it serializes the data. See how that tutorial serializes data and it might give you some ideas how to implement it in your program.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Can you link me to a site?Please note I want to open the standard musical sounds like:cymbal crash.base drum sounds.

google for them.

If all you want are the sound files, then try these

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Are you online?

Look next to my name -- see that round circle? If its green then I'm online, if it's grey then I'm not.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What compiler are you using?

Read this related thread

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I suppose OpenGL or DirectX have sound API functions.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

any body have any good way to learn it?

Yes --

  • Buy a book and read it.
  • Go back to college and take a few programming courses
  • Read some online tutorials
  • Stop spamming your sig links
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>if anyone could help me get the code correct and working would be really great.

You need to state the problem(s) you have with the code and post a few of the error messages your compiler produced. We are not here to do your homework for you.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>fatal error C1083: Cannot open include file: 'ffmpeg/swscale.h': No such file or directory

It should have been pretty obvious that the compiler can not find one of the include files. Check your computer and find out if you have swscale.h

>>error C3861: 'mkdir': identifier not found
You need to include the header file that declares mkdir()

>>error C3861: 'getopt': identifier not found
My guess is that the program was written for *nix. For MS-Windows or other operating systems you may have to write your own version of getopt(), or find a freeware version on the web.

Kreddy89 commented: that was helpful. thank you. +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

When your first computer had no harddrive and only two big floppy disk drives.

and the fastest modem available was 300 baud.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

don't run the installer, copy the installed folder. who runs the installer of a 16bit compiler?

I don't have an install folder, just a bunch of *.zip and *.cab files. Attached is a list of the files

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

All the code beginning on line 13 is not inside any function. The function started on line 9 ends on line 11, and you did not define any other function name in any of the remaining lines of code.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If that turboC compiler is working for you ok with xp than don't upgrade to Windows 7. There is supposed to be an XP compatability mode but it is not in the Home Prem version that I have (at least not that I know of). I also have 64-bit version of Windows 7 and the error message I got when I tried to install TurboC was that the installer was not compatible with 64-bit Win7.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Sorry, but I can not help you because TurboC can not be installed on Windows 7 os (I just tried it).

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

...when you can remember having to use an ACTUAL dial to dial a telephone number.

Or a crank telephone

Or remember watching this presidential campaign ad on tv

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Scrap that old IDE/compiler and get either free Code::Blocks/MinGW or VC++ 2008 Express. But if it's at school then you may not have a choice.