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

You dont', and you shouldn't. c() should not care who called it, but just do its job and return the results (if any) to the caller.

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

Here's an example win32 api project. The code not posted was just generated by vc++ 2010 express IDE and is not relevent. Note that the TimerProc() doesn't have to call KillTimer() but it should if the TimerProc() will take longer to process than the amount of time between calls to prevent re-entrant problems. You can always call SetTimer() again at the end of TimerProc() if needed.

VOID CALLBACK TimerProc(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime)
{
   KillTimer(hwnd,idEvent);
   MessageBox(hwnd,"Hello","Testing",MB_OK);

}

...
...
//
//   FUNCTION: InitInstance(HINSTANCE, int)
//
//   PURPOSE: Saves instance handle and creates main window
//
//   COMMENTS:
//
//        In this function, we save the instance handle in a global variable and
//        create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
   HWND hWnd;

   hInst = hInstance; // Store instance handle in our global variable

   hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
      CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

   if (!hWnd)
   {
      return FALSE;
   }

   ShowWindow(hWnd, nCmdShow);
   UpdateWindow(hWnd);

   if( SetTimer(hWnd,1,1000,TimerProc) == 0)
   {
       DWORD dwError = GetLastError();
       char buf[255] = {0};
       FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,0,dwError,0,buf,sizeof(buf),0);
       MessageBox(hWnd,buf,"Error",MB_OK);

   }

   return TRUE;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It depends on the job. In one job I did everything too from design to coding and on to testing. That was because I was the only programmer in the company. In other jobs I did only design and coding for only a small part of the program because I was a member of a team of about 200 computer specialists.

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

Ancient Dragon : Oh wow :) , nice , never thought about that.
So u mean to say that even a value returned by a main can be caught by say another program which spawned it and carry out operations... Nice Sir!!!

But in the event of a program not being spawned by other, ie in normal cases, who receives the value returned by main ? Is it the Shell (in order to determine whether the program has completed successfully or not) ?
This is what StackOverflow says
"By convention, your program returns an integer value (the return value of main) to the shell to indicate whether the program completed successfully (a zero) or non-successfully (non-zero, often related to an error code)."

When no other program or shell script has spawned the program then the os will most likely just ignore the return value. Afterall, the os doesn't really care whether the program completed successfully or not. And in some cases the return value doesn't mean success or failure at all, it could mean something else. 0 or 1 (sucess or failure) is the normal thing for main() to return, but there is nothing to prevent main() from returning other integer values.

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

Some programs spawn other programs, for example program A calls program B. In that case the return value of main() in program B can be caught by program A and used to determine if program B completed its task successfully or not. That's not the only reason, but just one of them.

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

Well, the most wanted terrorist was found in pakistan.

>>it's ok for the US to attack civilians
Its never ever ok for anyone to deliberately attack civilians. But in war, errors are made and sometimes civilians do get killed.

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

>>Narue : Sorry sir

Narue is a woman (with children) :)

>>Why did u say, Its int main and not void main ??
Read this link

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

I don't think there is a list -- they just make them up as they go along :)

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

>>I just want to ask,do you hate your job?

Nope, never did. If I haded the job then I'd quit and go work somewhere else where I liked it. I see no point in doing something I don't like to do, which is exactly why I'm not a farmer today. A job is not really "work" if you like what you are doing.

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

lines 17 and 18 can be combined sprintfstr1,("%d.%d", num1, num2); , then delete line 20 which calls strcat(), and delete str2 because it is not needed.

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

If you enter *.* from the keyboard then just concantinate the two strings. Simple.

char path[255] = {"c:\\myfolder\\};
char file[] = "*.*';

strcat(path,file);
FindFirstFile(path, ...);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Logically speaking , you should be able to put a clrscr() anywhere right ?
Wrong.

1. Its int main, not void main()

2. In C programs all variables must be the first things declared in a block of code. A block of code is one surrounded by { and }

3. clrscr() is a non-standard function found mostly in old ancient borland compilers such as turbo c. If that's the compiler you are using then you probably need to include the appropriate header file that contains its function prototype. It might be in dos.h, but I don't know.

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

Just say the word and I'll gladly go to c++ forums and make sure your rep drops to -10000 too :)

jon.kiparsky commented: You're so very public-spirited, it's just heart-warming. +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Terrorist groups are as plentiful as McDonalds francises.

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

My sister's age can :)

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

I thought it was one of the seals who was on the mission, but I may be wrong.

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

My sister -- she is still alive but I've always looked up to her as if she were a Goddess.

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

... you think you know it all.

Most teen agers are like that.

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

line 14: scanf("%f",&price[10]);

You need to use the loop counter as the index into the array, such as scanf("%f",&price[count]); And your program does not contain an infinite loop, line 10 is the correct way to code it.

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

maybe there is already one or more keys in the keyboard buffer ??? I don't know a thing about MIPS assembly, but that is usually the cause in MS-Windows and *nix programs. Check the contents of the buffer to see if that is what happened. You might have to clear the buffer first before calling syscall so that you can easily see any changes to its contents.

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

One of the SEALS was interview on CNN last night and his face was not blurred out. He didn't talk much about the mission details, but did briefly explain how they trained a month or so for it and that their first concern was for each other's safety. Which means it was a carefully planned mission, not s spur of the moment thing as you might see in the movies.

We will probably see a Hollywood movie about this during the next year.

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

No one suggested that killing OBL is going to end the war on terriorism. We were after him specifically because he was the mastermind of 9/11 attack on the world trade center towers in NY City. The war on terror will probably continue forever, just as the war on drugs has never ended.

Now that OBL is dead it is time for USA to pull out of that reagon of the world. If they want to continue to terrorize themselfs then so be it, I don't really care.

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

I have never heard that mentioned on any new broadcast, including CNN. I'm guessing it was just a false rumor. But if it was true the government will most likely treat it like a closely guarded military secret weapon.

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

I think we already to something similar -- people who post "gimme the code" are ignored and/or down voted. Regular DaniWeb members do not generally provide answers to postes who show little or no effort. That's probably about the best we can expect.

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

And how do you intend to calculate the 10%? Once I reach 10% do I just stop in mid sentence?

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

Does it include a plane-ticket? :D

Do you think this is "Wheel of Fortune" ;)

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

When you use: for (int i=0;i<length;i++) And others use: for (Object o:array)

When you (me) have no idea what your talking about :)

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

I'm curious as to how far you want to take that parallel. Do you mean to draw an equivalence between Cotton Mather and Osama bin Laden? Or was that meant to be taken a bit more loosely than that?

Both were terriorists as we define it today. The parallel is more a matter of degree to which they acted and the religious infulence the had.

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

Of course USA and europe are not without sin either. Reference the Salem Witch Trials and the Christian Crusades of the 2nd century AD. Even today American Christians sing Onward Christian Soldiers in church most Sundays.

jingda commented: Was salem involved +0
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

But some people and scientist said that he should be given a proper burial

Seems the arabs don't want him either (link)

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

I doubt it will change anything because there are other people just like him who will take his place. The way I heard it is that we didn't just find his body, someone deliberately shot him in the head.

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

To do a quote predator go to post reply and delete away the number beside the name you see in the box

That wasn't the problem. He didn't close the quote tags with [/quote]

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

Have you all seen the movie 1991 King Ralph staring John Goodman? If not, then you should because its a halarious satire about the royal life.

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

Dill pickles and two barbecued hamburgers.

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

try (dev c++) its free and open source

Too old and uses obsolete version of MinGW. Use Code::Blocks instead, and its supported on both *nix and MS-Windows.

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

Of all those, I only use F5, F5, F9, F10 and F11 because those are the ones for compiling and debugging. I also like Ctrl+[ and Ctrl+] keys, which are macros for finding beginning and ending {, [ and (

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

Yes you are using the same outdated compiler. Uninstall Dev-C++ as well as its compiler, then re-install Code::Blocks and its new compiler.

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

you can get the sdk on DVD for about $5.00 or so. The SDK doesn't come with VC++ 2010 express.

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

mfc, win32 api, windows forms, or something else?

For button push, just implemement it on the OnButtonClick even handler (might be called something else depending on what gui you are using).

For F1 you will have to override the WinProc() event handler or enable a keyboard event handler function. Some of these google links might help you.

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

1. Do not use *.cpp files as includes in other *.cpp files. rename those two *.cpp files (functions_prototype.cpp and struct.cpp) to *.h.

2. Add <string> to functions_prototype.h. Many compilers, such as vc++ 2010 do not automatically include that header file.

3. Several times you have forgotten to add 1 to strlen(tName) when allocating new memory.

4. in saveToFile(), calculate the length of tName only once and use that calculation in the loop. Its bad practice to call strlen() in a loop when the length never changes because its too time consuming.

//add "+" to join name with spaces  
        size_t len = strlen(tName);     // <<<< AD
        for (size_t j=0; j<len-1; ++j)  // <<<< AD
        {
             if(tName[j] == ' ') tName[j] = '+';
        }

5. MenuOperation(), case '1'. Here is the correct way to clear the cin input buffer. Read this thread for more detailed information.

//cin.ignore(); // <<< AD
         //cin.ignore(0);
         //cin.clear();
         //cin.sync();
         cin.ignore ( std::numeric_limits<std::streamsize>::max(), cin.widen ( '\n' ) );

There are other errors that I have not tried to find. Fix the above and you will be able to do more than just the first record that you mentioned. I don't know what compiler you are using, but you need to learn how to use your compiler's debugger so that you can easily single-step through the program and set breakpoints. I found all the above problems in about 15 minutes doing that with vc++ 2010 express.

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

main() never calls function search_number().

Also, you need to write a function that inserts a new node in the linked list. If the list needs 1,000 nodes you don't want to do what you coded that many times when one small function will do it for all of them. google for linked lists and you will find example code how to do it.

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

1. Don't use that compiler because its too old and use obsolete version of MinGW. Replace it with Code::Blocks

2. You have to download and install the free Microsoft Windows SDK from here.

3. After you do the above, reverse lines 1 and 2 so that windows.h is included before winnet.h because there is stuff in winnet.h that requires stuff from windows.h