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

how about system(code.c_str());

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

probably becuase there are still keys in the keyboard buffer. And since you are writinig a c++ program why aren't you using cin and cout? There is a sticky thread at the top of this c++ board that explains how to flush the input buffer of all keys -- you should read it.

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

Obama is communist and y'all see what will happen to us and the world itself real soon. NWO is coming people, WAKE UP!!!

You're a little like Chicken Little -- The Sky Is Falling! The Sky Is Falling! The Sky Is Falling! The Sky Is Falling! The Sky Is Falling!

>>Obama is communist
Rediculous! You have been reading too much on www.f***france.com (replace the stars with that famous banned word)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Comatose commented: Hahahaha :) +9
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Just now the Illinois senate voted 59-0 to sustain the impeachment of Blagojevich and remove him from office. The Lt Gov will assume that office today.

Hurray! Hurray!

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

Oh, now I see what's wrong with it. str[5] doesn't have enough room to hold "Hello", which is 5 characters plus 1 for the string's null terminator. str[6] is the minimum for "Hello".

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

works great for me using vc++ 2008 express

#include <iostream>
using namespace std;

int main()
{
char str[25];
cin >> str; // user types "hello"Assume that: char str[ 5 ];

cout << str << "\n";
}

The only thing I can think of why your book thinks there is an error is that it should be std::cin >> str; The program would need the std:: part if you didn't state using namespace std as I did at the top of the program.

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

In Dev-C++ select Project --> Project Options, then enter the path as shown in the attached picture. Don't know about *nix

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

nothing wrong with #1.

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

line 9: zPtr just contains some random address value, so incrementing on line 9 is meaningless.

line 18: thats just wrong -- use either *zPtr or zPtr, but not both at the same time.

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

what operating system? If MS-Windows you are downloading the wrong file -- download the *.zip file at the end of the list in the link that Niek posted in post #2 above.

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

your link doesn't work

Error - The file could not be found. Please check the download link

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

We don't discuss how to hack here at DaniWeb.

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

never tried it (I don't think I have anyway)

Cold leftover pizza

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

This is game is simple. You just rate how well you know or recognize the person above you on a scale of 1-10.

I don't like this thread -- that's what reps are all about.

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

what computer language? Or can you use anything you wish?

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

Had you terminated the strings with "\n" instead of "\0" then you could have simply called fgets() to read the strings back into memory.

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

re-read my post -- all you have to do is close the file then reopen it with "w" flag. Pretty simple stuff.

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

>>What ink is used to print dollar
Green.

Nick Evan commented: best answer :) +12
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Maybe (hopefully) someone will tear it down and replace it with homeage to Walt Disney for his lifetime achievement in the film industry. Or remove the pictures and replace them with grafitti.

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

When ready to clear the file out just close it and reopen with the truncate flag.

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

Good one :) Too bad the sound was a little choppy.

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

Chertoff who???

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

I found this when googling for the lyracs of Bob Hope thream song. Posting it here because I enjoyed this video and thought you might too.

http://www.youtube.com/watch?v=xWHf_vYZzQ8

Gerryx1 commented: A worthwhile watch, good musuc, funny. +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I hope all of you Obama fanboys are proud that you finally elected your closet terrorist into office so that he could shut down Gauntanamo Bay and release all his muslim friends, and while he was at it he shut down all over seas prisons linked through the CIA so that we no longer have any control over who attacks our country.

You are welcome. :)

I don't know if any of you obama people realized that not once after 9/11 was the US struck by terrorism since Bush put his foot down and did somthing about it.

Nobody said otherwise, so you are just mouthing off to mouth off.

But anyways, y'all can go hug a tree somewhere else and cry about peace on your own time.

Go cry somewhere else. We don't need crybabies.

Congradulations on destroying America from the inside as we know it. Ill be moving to Canada now... laters

Great News :) :) Don't let the door hit you in the ass as you leave.

Ezzaral commented: I endorse this message :) +16
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

OMG that has to be an extremely sloooooow program. A more efficient way would be to keep the times in the vectorl so that they can easily be referenced, maybe something like this:

struct files
{
     std::string filename;
     FILETIME  tm;
};

vector<files> list;

line 18: are you sure that is how its coded in your program? std::vector &inFiles doesn't make any sense.

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

Welcome to DaniWeb -- we are pleased that you found us useful, and now you can actively participage in the discussions.

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

Yes with Dev-C++ you have to add code at the bottom of the function to prevent main() from immediately returning to the OS. cin.get() (c++) or getchar() will normally do the trick.

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

Those registry functions are only available on MS-Windows 2000 and newer. They are definitely not available on *nix, and possibly not on Win95/98/Me/NT

If you want complete portability then I would suggest you store them in an encrypted file instead of the windows registry.

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

Thanks sir. Sir's can I post the code snippet that I have now so far? thanks. :)

Post away :) and don't forget to use code tags so that I don't have to do it for you.

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

worked perfectly ok for me

Enter first number: 10
Enter second number: 20
Sum is 30
Press any key to continue . . .

Perhaps its the compiler you are using -- what compiler and operating system?

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

I don't hate the functions in conio.h, I just whish they had become part of the C standards so that they could be used more frequently. kbhit() and getch() are very very useful functions, but perhaps they never became part of the standards is because they would be difficult at best to implement on some operating systems.

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

answer is here

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

Under MS-Windows the correct way to do it is to save the UserName and Password in the registry -- and encrypt the password because the registry can be easily viewed by anyone. Its not very difficult to read/write to the registry, but here is a c++ class if you want one. I'm sure you will find others if you google for "c++ registry class" or something like that.

When your program starts the first thing it should do is check the registry to see if the UserName and Password exists. If it does not exist in the registery than prompt for them as you suggested. If they doe exist in the registry then don't prompt.

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

>>i am making a 3d first person
what is that? I've heard of a 1st person shooter, but 3d???

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

>>What am I missing?

You are missing WinProc() function as explained in the error message.

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

start here

#include <iostream>

int main()
{
   // put your code here
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

boost xml parser. I never used it so I can't answer any questions about it.

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

>>if( kbSize == 2000 || 3000 || 4000 || 5000);

There are several things wrong with the above statement:
1) the semicolon at the end makes it a do-nothing statement.
2) it should be formatted like this: if( kbSize == 2000 || kbSize == 3000 || kbSize == 4000 || kbSize == 5000)

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

check the spelling -- capatilization is important

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

VT_BSTR can not be directly converted to std::string because a BSTR is UNICODE wchar_t*, not char*. You have to use one of the conversion functions. Here is an example, when compiled with VC++ 2008 Express you must compile for UNICODE (the default)

#include <windows.h>
#include <tchar.h>
#include <string>
#include <iostream>
using namespace std;

int main(int argc, char* argv[])
{
	// allocate a BSTR string
	BSTR b = SysAllocString(_TEXT("Hello World"));
	std::string str;
	// get length of the string.  Number of bytes
	// allocated to BSTR divided by size of wchar_t
	// is the number of characters in the BSTR.

	size_t sz = (*(long *)(b-2))/sizeof(wchar_t)+1;
	char *buf = new char[sz];
	// convert from wchar_t* to char*
	wcstombs(buf, b, sz);
	str = buf;
	cout << sz << "\n" << str << "\n";


	return 0;
}

VC++ 6.0 has a macro _L("text") that forces a char* to wchar*, but I could not find it in VC++ 2008 Express, hence the use of _TEXT and requirement to compile for UNICODE. But for the OPs purpose this is just adademic because his strings are (presumably) already BSTR UNICODE.

BSTRs can contain other binary blobs as well -- there is no requirement that they be null-terminated UNICODE strings. So if the BSTR contains anything other than a standard string then the code I posted above will not work correctly, nor should you attempt to assign the blobs to a std::string object.

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

>>A loop and a decision perhaps?
something similar to this? I know its not exactly what LucyB wants, but google for "flow charts" and you will find other examples.

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

This is c++, not C. So use c++ ifstream to read the file one word at a time. Is there a need to keep the individual fields with the entire line? If not, then you don't have to keep them in memory, just read the file one word at a time

#include <fstream>
#include <string>
using namespace std;
...
...
ifstream in("in.txt");
std::string word;
while( in >> word )
{
   // do something
}

Or if you need to retain the entire line

#include <fstream>
#include <string>
#include <sstream>
using namespace std;
...
...
ifstream in("in.txt");
string word;
string line;
while( getline(in, line) )
{
    stringstream str(line);
    while( str >> word )
    {
         // do something
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

fstream us standard c++ class so it works the same on all operating systems that support them.

WritePrivateProfileString() does nothing more than rewrite the file with the new string in the form <tag name>=<value> . You can do this yourself with ofstream.

ofstream out("filename.ini");
out << "[MySectionName]\n"; // beginning of section
out << "LName=" << lname << "\n";
out << "FName=" << fname << "\n";
...
<etc. etc. for all fields
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>and all the code is correct
Then why is getWord() never called to read the words from the file?

You are on very dangerous ground with that replace function. The intent of the function is to replace one word with another word within the sentence. Lets say I enter a sentence that has 49 character, the max allowed in the word array. Now lets assume I want to replace the word "Iowa" with the word "Mississippi", which is longer than the original word. Result: buffer overflow because word can't contain all those extra characters.

>>I have a problem in the second parameter in the func
What is the problem with it?

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

I'm not sure what you are trying to accomplish, but that header file is really unnecessary. Both functions are coded in code.c and the header file will not prevent that. But you should get an error in main.c because fcn2() was not declared (because ifdef'ed out in the header file).

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

Here is a list of file formats -- there might be more, I don't know. I didn't know a.out was a file format -- just thought it was a filename.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
std::vector<std::ofstream*> fileList;
            fileList.resize (argc - 1);
            for(int i = 1; i < argc; ++i)
            {
                  fileList[i] = new std::ofsteam(argv[i]);
            }

All taking about the line fileList[i] = new std::ofsteam(argv[i]); From what I've gathered from google this happens when you forget to #include stuff but I have ofstream and vector in my includes.

That is correct -- I didn't post a complete program. You will have to add the #include's. If you did include those and still have compile problems you need to post complete code, not just partial.

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

Ancient Dragon

In may program , the ID start of -1 ;
(( the value from the teacher :( ))

so, I think the function serch from +1.

But that should be incremented to 0 before writing to file. -1 is just a placeholder that says it has not been initialized yet.

My class contain only int and float ..
so Maybe is work .?

Most likely, yes. But I don't see how you could have a Personnel class without a name ??? Unless you are not working with a Personnel class but something else.

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

Also, lines 13 and 14: why not just output it as a string with one simple line: cout << student[i] << "\n"; . The j loop is completly unnecessary.