Console Window flashes on and off while running C++
Hi friends,
I am very new to the C++ programming language. I am facing very strange problem. When I tried to search in Google, I can't find the appropriate solutions. So thought posting here will prove helpful for me. My problem is when I try to run the basic C++ program, the Console Window flashes on and off. I have written the proper code because the same code was working on my friends system. Also I tried to copy and paste the codes from the getting started with C++ sites. But the same problem is persisting. Please help me to sort out my problem.!!:rolleyes:
Re: Console Window flashes on and off while running C++
The console window flashes on and off, mainly when you are not using the method that isn't calling from the command line and you are using the command line program. I think that same thing is happening in your case also. Your window is flashing on and off because it is a command line program and you aren't calling it from the command line program. I would like to suggest you to go first to command line and then try calling the program. If there is any output/error messages, it will be shown to you. Hope that using the command line will fix your issue.
Re: Console Window flashes on and off while running C++
Have you done the settings in the Environment Variables?? Because the problem can occur if you haven't set the Environment Variables properly. According to the Microsoft "Environment variables are strings that contain information such as drive, path, or file name. They control the behavior of various programs. For example, the TEMP environment variable specifies the location in which programs place temporary files". You will have to set the path for the Environment variables. The path to a file is basically its address on the computer. It tells programs how to find a file. It is the drive plus any directories and sub-directories where the file is located. The %PATH% environment variable specifies the command search path. I think that setting the proper path will resolve your issue.
Re: Console Window flashes on and off while running C++
You can set the Environment Variable by following the steps given below :
- Right click on the "My Computer" icon placed on the desktop.
- Then select the Properties option.
- In properties option, select the Advanced tab.
- After clicking on Advanced tab, a dialog box will appear.
- Then click on the button "Environment Variables".
- To create a new variable, use the "New" button. There are also buttons for editing and for deleting variables.
- The box for adding a new user variable will appear.
- Box for editing a variable; in this case it is the PATH variable. Be sure to remember to separate directory names with a semicolon.
- Browse the path of the desired directory and then Add the path.
Re: Console Window flashes on and off while running C++
You can also add the folder using the add-on tool Setx.exe. This specific application is not the part of the standard Windows XP setup, but it is a command-line tool called setx.exe that is included in the Windows XP Service Pack 2 Support Tools. You can make the permanent changes in the environment variables by using this tool. You can add the New Folder which is located in C: drive by using the following command :
setx path "%PATH%;C:\New Folder"
Re: Console Window flashes on and off while running C++
If you have enough knowledge about the editing the registries, then there is another way to make changes in environment variables. User environment variables are stored in the Registry in the key:
HKEY_CURRENT_USER\Environment
System variables are found in the key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
The %PATH% must be stored in the registry as a REG_EXPAND_SZ registry value in the form that needs to be expanded. Editing the Registry is primarily for scripts used by systems administrators and is not recommended for the average PC user.