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

Again, the character buffer is not null-terminated. Why not just do CharName >> NameBuffer; or CharName.getline(NameBuffer,NameLength); Better will, declare NameBuffer as std::string instead of char*

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

ReadFile() does not null-terminate strings -- it treats the file as if it were a binary file. Instead of CreteFile() and ReadFile() why don't you just use standard C++ fstreams. Just because you are writing a win32 api GUI program doesn't mean you can't use c++ fstream or other STL containers.

>>line 7: int NameSize = sizeof(hFile);
Huh? That will not give you the size of the strName(), or even the size of the file.

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

DaniWeb has server problems occasionally and sometimes I have a problem now and then like you mentioned (maybe only about once or twice in any given week). It might be that you are trying to make a post at the moment their servers go bonkers. But since you were able to post this thread I assume the server was working ok for you at the moment.

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

>>Don't #include C header files in your header files
That's one of YOUR rules that is frequently broken. I agree with the general pholosophy, but it doesn't really work that way in real-world programs and libraries.

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

If you know your friend's name then use the advanced search. Click the Search button without entering anything and you will get the advanced search window. You can search for any DaniWeb member that way.

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

Yes, post it.

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

There are a couple options
1. If your compiler supports conio.h then it contains a couple functions that will do what you want.

2. Use OS-specific api functions. For MS-Windows there are some console functions you can use (link here)

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

>> I think what i said is confusing, do yo think so?
Clear as mud :)

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

Activity points is something that was started here just within the last few months, I don't recall when. But everyone started out with 0 activity points and went from there. That's why you will see some members with large post count and small activity points. Take me for example. I have a huge post count but not so large activity points because I'm not as active here at DaniWeb as I once was.

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

The error message sounds like you have more than one *.c file with main() in the project. Check your project and remove one of the files.

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

Look at the logic of the code. Every time you select menu 1 the program allocates an entirely new array of Player objects. The previous array is thrown away, lost forever, and a memory leak occurs. If an array already exists then you need to figure out how to reallocate the array without losing any memory or the previous values in the array. This is one reason why programmers use the std::vector container, because it does all that for you so you can concentrate on the logic of your program instead of how to manage arrays.

And yes, the constructor has to be called for each item in the array, once for value of num_players.

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

Correct. An even better method would be to use the std::vector container. But you may not be ready for that yet.

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

line 52: where is player declared? The declaration on line 50 is not in scope at line 52, so it can't be used. Move the declaration of player from line 50 to just after line 42.

why is position a pointer? line 27 only allocates one of them. There is no point using a pointer to allocate a single integer.

predator78 commented: gettin me straightened up slowly but surely lol +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

struct dirent must not be declared as a pointer

struct dirent entry;
 while ((entry = readdir(&mydir)) != NULL)
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>I wrote this script for my classmates where we shoot at each other
Remind me never to go to your school.

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

its nearly the same thing

string in = "123";
stringstream out;
out << in;
int thetime;
out >> thetime;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Another way to do it is to clear the input buffer after cin returns. See this thread how to do that. You will probably also have to clear cin's error flags, such as cin.clear().

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

get the data as a std::string then convert it to integer.

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

Yes, that is ok. And its [icode] , not IQUOTE

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

int delay = 0; initializes the variable when it is declared delay = 0; is done when you need to re-initialize the variable, such as when its used within a loop as you posted so that it can be re-used for something.

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

Never saw it -- I don't think its broadcast to USA. Unfortunate.

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

>>I compile it like: gcc -lpthread programName.c and it compiles fine

How can you say that and then post the error messages that your compiler gave you???

Try reversing the order of the two includes. There might be something in pthread.h that depends on stdio.h but just a guess.

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

Where is function speedTest() being called? Add some code inside that function to make sure its being called. Also just comment out the loop on lines 7-10 to make sure that isn't causing a problem.

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

could it be a permissions problem? Does the program have required write permissions? Change the path of the output file to somewhere you know has ok permissions, such as your home directory.

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

worked ok for me on MS-Windows 7 and vc++ 2010 express.

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

>>Most modern computers have little endian byte orders

No. MS-Windows and *nix are both different, and both modern operating systems.

>>Program should work on all systems, only thing I am sure is that I am reading 2 byte integers

Your program is going to have to be a bit smarter than just blindly assuming a certain byte order. The program will have to figure out which byte order is being used on the os and act accordingly so that it can read the binary data file correctly.

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

>>line 9: number1= buffer[0]+ (buffer[1]<<8);

Try this: number = *(short *)buffer; This assume sizeof(short) = 2 on your computer. There is no guarentee that is true on every computer.

That may not work either if the binary file was written in little endian format and you are attempting to read it on a machine with big endian format. More info about that in this wiki article

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

Yes, the first is a pointer while the other is not. Example

struct something
{
  int variable;
  // blabla
};

struct somtehing* ptr; // ptr->variable
struct something obj; // obj.variable
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Would you clarify your question because I don't know what you asked???

Scroll down to the section titled "Converting from wchar_t*". Pay attention to the functions that are used, especially wcstombs_s().

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

For Microsoft MFC CString to char*, see this post. Just use CString's GetBuffer() to get the pointer to the wchar_t*.

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

You are using nasm in MS-DOS mode (command prompt). Yes, they can not be used in win32 32-bit program. If that is what you want to do then interrupts are out of the question.

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

All the funbctions you need are in int 21h. You can also use keyboard functions in int 16h, which are more flexible. Think of how you would use c language getchar() to get keyboard input and put it into a buffer. The same with assembly, using int 16h functions to get keyboard input.

int 21h has functions to either display a single chacter or a whole string (termiated by $ instead of '\0')

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

Is this for an assembly language class you are taking? If yes, does your teacher allow you to just call C library functions? That sounds like cheating to me.

line 19: what is the value of ecx?? You need to declare data for scanf() to store the results, just like you would have done in C languge.

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

sqlite is fine for very very small jobs. But so are just simple text files. For large jobs you will want an SQL compliant database such as MySQL of even MS-Access. In that case you will have to learn SQL (Structured Query Language) Links to tutorials here

Here is another tutorial geared specifically for MFC

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

Example of CreateProcess() which calls Notepad.exe to display a text file. You need to read MSDN article to understand all the parameters. This example will also wait until you close Notepad before continuing.

#include <Windows.h>

int main( )
{
    char args[255] = {0};
    STARTUPINFO sinfo;
    PROCESS_INFORMATION pinfo;
    memset(&sinfo,0,sizeof(sinfo));
    memset(&pinfo,0,sizeof(pinfo));
    sinfo.cb = sizeof(sinfo);
    strcpy(args,"Notepad.exe c:\\dvlp\\test.bat");
    if( CreateProcess(NULL,args,0,0,0,0,0,0,&sinfo,&pinfo) )
    {

        WaitForSingleObject(pinfo.hProcess,INFINITE);
    }
    return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

As for using either CreateProcess() or ShellExecute(), why don't you try both and see which one suites your purpose better. CreateProcess() gives you the most control over the process to be created, but ShellExecute() may be a little easier to use.

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

close.
>>if(password == "123456"

Since password is an integer you don't need those quotes, and you do need a ) at the end if(password == 123456)

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

There is no reason for the parameter to the function. Also, the || operator is correct.

string CheckPassword()
{
    string pass;
	bool first = true;

	do
	{
		if(!first) 
		{
			cout << "Password must be greater than 5 characters and contain no spaces:\n";
	    }
		
		cout << "Enter your Password:\n";
	    getline(cin,pass);
		first = false;
	}
	while (pass.length() <= 5 || pass.find(' ') != string::npos);
	
		
		return pass;
	
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

None other than the find() method. The while loop just needs a little adjusting to make it work correctly. use and && operator instead of or || because you want to check for less than 5 AND no spaces.

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

find() returns string::npos if not found, which is not the same thing as 0 or NULL.

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

I wonder Ancient Dragonn, did you build using the default code::blocks settings with mingw compiler?

Yes.

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

Worked fine for me. You probably need to make all three files part of the project, see thumbnail.


>>Is there a way to automatically link all include files
No.

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

>>how does a lone programmer with a few languages at his disposal make awesome software

Depends on what YOU consider "awsome". Awsome software such as Microsoft Word or Paint, is written by a team of programmers, analysts and graphics designers. And it usually takes years to design, code and test.

Of course you can write your own shareware or freeware programs that do neat little things, but I wouldn't consider them "awsome".

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

That's where we found out that Narue is really an alien from Venus (see the UFO thread).

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
sergent commented: 3 +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Whats in there?

Make a monetary donation to DaniWeb and you too will be able to enter Area 51.

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

^ Sick Narue on you for starting this stupid game.

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

post declaration of nameList. If it's std::string namelist then there will never be a NULL entry.

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

I got that stupid message too, so I disabled it. If you are running Norton 360, click that green tool on your desktip and it will bring up a Norton window. On that window select menu item Settings, then Antivirus link. From there you can turn off SONAR Protection.

With VC++ 2010 Express (which I also use) you have to put the file you want to open in the same folder as the program's *.cpp files.

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

If Norton were the cause then you would have gotton a Norton error message. If file.open() fails the only reason on MS-Windows is that the file is not in the directory you think it is. What compiler are you using?