It's been quite a while since I've spent any time practicing C++ code, because I haven't had regular access to a decent compiler, but no more;) I just got done installing Visual Studio 2013 Professional on my computer. However, when I ran my Hello World program, the console window didn't stay open for any more than a fraction of a second. I can't read any of my programs' output until I fix this problem. So, how do i get Visual Studio to not automatically close it?
↧
Visual Studio 2013 console window doesn't stay open after I run my program
↧
How to prevent buffer overflows?
I have declared some local variables in various places inside a function.
I have checked the boundary checks option in the C++ option section.
But sometimes some local variables will get overwritten by previous variables,
so it becomes garbage. I don't know why, recently, this happens more often in the VS2010 compiler
I can't recall what options I have changed to the project properties.
How to prevent this problem from happening again?
Like this code snippet, iBone is overflowed by nBones, and it becomes an extremely large value...
Thanks
Jack
I have checked the boundary checks option in the C++ option section.
But sometimes some local variables will get overwritten by previous variables,
so it becomes garbage. I don't know why, recently, this happens more often in the VS2010 compiler
I can't recall what options I have changed to the project properties.
How to prevent this problem from happening again?
Code:
// one set of bones per meshcontainer
DWORD nBones = meshcontainer->dwNumBones;
for (int iBone = 0; iBone < nBones; iBone++)
Thanks
Jack
↧
↧
int x=y int x(y)
Hi, id like to know the difference between these, and what does each means, thanks in advance
↧
Printing the same line twice from a file and not the others.
When I run my code I get only the first line(Adara Starr,94) of the file printed twice. I'm having trouble getting it to read all of the line and print them all out. Any help will do. Thank You.
The "grades.txt" file looks like this:
Adara Starr 94
David Starr 91
Sophia Starr 94
Maria Starr 91
Danielle DeFino 94
Dominic DeFino 98
McKenna DeFino 92
Taylor McIntire 99
Torrie McIntire 91
Emily Garrett 97
Lauren Garrett 92
Marlene Starr 83
Donald DeFino 73
The "grades.txt" file looks like this:
Adara Starr 94
David Starr 91
Sophia Starr 94
Maria Starr 91
Danielle DeFino 94
Dominic DeFino 98
McKenna DeFino 92
Taylor McIntire 99
Torrie McIntire 91
Emily Garrett 97
Lauren Garrett 92
Marlene Starr 83
Donald DeFino 73
Code:
#include <fstream>
#include <iostream>
using namespace std;
const int MAXNAME = 20;
int main()
{
ifstream inData;
inData.open("grades.txt");
char name[MAXNAME + 1]; // holds student name
float average; // holds student average
inData.get(name, MAXNAME + 1);
while (inData)
{
cout << name;
inData >> average;
cout << average << endl;
// FILL IN THE CODE to print out name and
// student average
// FILL IN THE CODE to complete the while
// loop so that the rest of the student
// names and average are read in properly
}
system("pause");
return 0;
}
↧
Visual C++ program help needed asap
hey guys, i'm new to programming in visual c++, and i am making a program in visual c++ about contacts management but instead of using file system i want to use Database but i'm not able to do so and it is very urgent.
please if anyone can help me.
please if anyone can help me.
↧
↧
Confused about when I can use toolbox tools.
I was trying to add a dialog to open a file, and I see it selected in the "Choose items" options, but I don't see it under the Toolbox to actually use. If I select "Show All" it shows up but I'm unable to do anything with it. Am I just completely misunderstanding how the Toolbox works? I've attached a screenshot to try and show what I mean ...
![Name: Capture.jpg
Views: 16
Size: 60.1 KB]()
↧
visual studio enterprise
wow!fantastic!
↧
Use of milli second / micro second / nano second in gcc
Hello,
How can milli second / micro second / nano second be used in gcc platform? What is the process, syntax?
Please help.
How can milli second / micro second / nano second be used in gcc platform? What is the process, syntax?
Please help.
↧
Assistance with enumeration in combination with user-defined functions.
Hello:
I am having a little trouble with an assignment that involves enumeration. While my code seems to work, my instructor informed me that I am only to use user-defined function, with for statements, while loops, switch statements in the main body. Embarrassingly, for whatever reason, I can't seem to wrap my head how I am supposed to rewrite my switch statement as a user-defined function.
Here is what the assignment is asking for:
1a) Define an enumeration type, triangleType, that has the value scalene, isosceles, equilateral, and noTriangle.
b) Write a function, triangleShape that takes as parameters three numbers, each of which represents the length of a side of thed triangle. The function should return the shape of the triangle. (Note: In a triangle, the sum of the lengths of any two sides is greater than the length of the third side).
c) Write a program that prompts the user to input the length of the side of a triangle and outputs the shape of the triangle.
And here is what I have so far:
Any help is greatly appreciated. Thank you.
I am having a little trouble with an assignment that involves enumeration. While my code seems to work, my instructor informed me that I am only to use user-defined function, with for statements, while loops, switch statements in the main body. Embarrassingly, for whatever reason, I can't seem to wrap my head how I am supposed to rewrite my switch statement as a user-defined function.
Here is what the assignment is asking for:
1a) Define an enumeration type, triangleType, that has the value scalene, isosceles, equilateral, and noTriangle.
b) Write a function, triangleShape that takes as parameters three numbers, each of which represents the length of a side of thed triangle. The function should return the shape of the triangle. (Note: In a triangle, the sum of the lengths of any two sides is greater than the length of the third side).
c) Write a program that prompts the user to input the length of the side of a triangle and outputs the shape of the triangle.
And here is what I have so far:
Code:
#include <iostream>
using namespace std;
//user-defined (enumerator) data type
typedef int side;
enum triangleType { scalene, isosceles, equilateral, noTriangle } shape;
void sideTri(side&, side&, side&);
triangleType triangleShape(side&, side&, side&, triangleType&);
int main() {
side a;
side b;
side c;
int type;
type = triangleShape(a, b, c, shape);
switch (type) {
case 0:
cout << "This is a scalene triangle." << endl;
break;
case 1:
cout << "This is an isosceles triangle." << endl;
break;
case 2:
cout << "This is an equilateral triangle." << endl;
break;
case 3:
cout << "This is not a triangle." << endl;
break;
}
return 0;
}
void sideTri(side& a, side& b, side& c)
{
cout << "Enter side a: ";
cin >> a;
cout << "Enter side b: ";
cin >> b;
cout << "Enter side c: ";
cin >> c;
}
triangleType triangleShape(side& a, side& b, side& c, triangleType& shape)
{
if (a == b && b == c) return equilateral;
else if (a == b || b == c || c == a) return isosceles;
else if (a != b && b != c && c != a) return scalene;
else return noTriangle;
}
↧
↧
CMenu ON_COMMAND problem
Hello
I have a Menu which shows but doesn't respond to command, i'm working for hours on it can't figure out what am i doing wrong.
in main.h i have:
in main.cpp i have:
The Menu appears fine but when i click a submenu, nothing happens :confused:
Anyone can help, please ?
I have a Menu which shows but doesn't respond to command, i'm working for hours on it can't figure out what am i doing wrong.
in main.h i have:
Code:
afx_msg void thingtodo();
Code:
ON_COMMAND(IDTHINGTODO, &CTESTDIALOG::thingtodo)
//
void CTESTDIALOG::thingtodo()
{
AfxMessageBox(L"Test");
}
//
void CTESTDIALOG::OnNMRClick(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
*pResult = 0;
POINT cursorPoint;
GetCursorPos(&cursorPoint);
int x = cursorPoint.x;
int y = cursorPoint.y;
CMenu menu;
menu.LoadMenu(IDR_MENU);
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
CWnd* pWndPopupOwner = this;
while (pWndPopupOwner->GetStyle() & WS_CHILD)
pWndPopupOwner = pWndPopupOwner->GetParent();
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, x, y, pWndPopupOwner);
}
Anyone can help, please ?
↧
Windows 10 Universal Apps / Feel lost
Hi all !
I'm coming from a Delphi background. Used it for many years and still using it. However, if we want to stay competitive, we have to shift our focus to Windows Apps development for certain products. The problem is my mind is stuck in windows forms development and I have a hard time making the shift. With Delphi, you had a form on the screen, dropped your components on it, set properties, and wrote the code behind it. When I look at windows 10 universal apps, I'm really lost and I don't know where to start. There is C#/xaml, C++/xaml and HTML/JS. When I take a look at xaml, it's really not as easy as designing a form. Xaml just expects you to know what to type. When I take a look at books, they will just teach you how to define a button, how to draw a line or show a picture but no real life examples are found in any book I checked. Then you have blend, is that the way to go ? I already spent hours on google, but didn't find really anything useful that explains what direction to go and where to start and more important how to become a skilled designer. Because knowadays I just feel you have to be a graphical artist to design a good looking user interface.
The apps we have to make in the future are not meant for a browser. So I guess HTML/JS is not an option for that. Don't know if I have to use C# or C++.
I'm not sure if this is the right forum, but I guess C++ is the best for the job ? So that's why I posted it here. I'm just wondering if there are people here who alse had difficulties to make the transition.
Sorry if my question sounds dumb :confused:
Many thanks in advance...
I'm coming from a Delphi background. Used it for many years and still using it. However, if we want to stay competitive, we have to shift our focus to Windows Apps development for certain products. The problem is my mind is stuck in windows forms development and I have a hard time making the shift. With Delphi, you had a form on the screen, dropped your components on it, set properties, and wrote the code behind it. When I look at windows 10 universal apps, I'm really lost and I don't know where to start. There is C#/xaml, C++/xaml and HTML/JS. When I take a look at xaml, it's really not as easy as designing a form. Xaml just expects you to know what to type. When I take a look at books, they will just teach you how to define a button, how to draw a line or show a picture but no real life examples are found in any book I checked. Then you have blend, is that the way to go ? I already spent hours on google, but didn't find really anything useful that explains what direction to go and where to start and more important how to become a skilled designer. Because knowadays I just feel you have to be a graphical artist to design a good looking user interface.
The apps we have to make in the future are not meant for a browser. So I guess HTML/JS is not an option for that. Don't know if I have to use C# or C++.
I'm not sure if this is the right forum, but I guess C++ is the best for the job ? So that's why I posted it here. I'm just wondering if there are people here who alse had difficulties to make the transition.
Sorry if my question sounds dumb :confused:
Many thanks in advance...
↧
File Open dialog problem
Hi,
I have a laptop which I use for development. It is connected to my local network (P2P connection thru the Windows sharing, no server).
Since it is a laptop, I can take it with me anywhere I want and continue developing.
In my program I use File Open dialog. What I notice is that when I'm not at home the File Open dialog execution takes a lot of time. Since the shared drives are not available, I'm guessing that it is trying to establish a connection to them and after the timeout period the dialog displays the directory.
Is there a way to prevent that and make it display immediately?
I quickly look over here, but couldn't find anything.
Trying to pull File Open dialog from the Notepad also takes a lot of time.
The trouble is that the dialog itself is displayed and then I need to wait until it shows the current directory.
I have a Windows 8.1 with MSVC 2010.
Thank you.
I have a laptop which I use for development. It is connected to my local network (P2P connection thru the Windows sharing, no server).
Since it is a laptop, I can take it with me anywhere I want and continue developing.
In my program I use File Open dialog. What I notice is that when I'm not at home the File Open dialog execution takes a lot of time. Since the shared drives are not available, I'm guessing that it is trying to establish a connection to them and after the timeout period the dialog displays the directory.
Is there a way to prevent that and make it display immediately?
I quickly look over here, but couldn't find anything.
Trying to pull File Open dialog from the Notepad also takes a lot of time.
The trouble is that the dialog itself is displayed and then I need to wait until it shows the current directory.
I have a Windows 8.1 with MSVC 2010.
Thank you.
↧
how to code a menu item to invoke a form
Dear fellows, after thinking it during long time, after searching a lot about the question, I´ve decided to post my question. I´m sorry, I couldnt find any answer to my problem.
Well the situation is that I'm developing a application to graph math equations using Visual C++ 6.0.
By the time, I get two forms:
One form used to introduce values to graph math equations of only one variable.
[IMG]C:\MyWorks\MY_Visual C++ projects\Graficador_Calculador\Graficalculador\step_002_Sin_BaseClass\fotos\para enviar\screen and form to graph equations of one variable.jpg[/IMG]
Another form used to introduce values to graph parametric equations.
[IMG]C:\MyWorks\MY_Visual C++ projects\Graficador_Calculador\Graficalculador\step_002_Sin_BaseClass\fotos\para enviar\screenAndFormParametricEquations.jpg[/IMG]
All right, When the application start, appear the menubar IDR_MAINFRAME within main frame window.
After clicking on FILE menu appears the menuitem NEW .
After clicking on NEW appears a little dialog box, below the NEW menuitem, showing the two forms. In this way I can choose which form I want to open.
[IMG]C:\MyWorks\MY_Visual C++ projects\Graficador_Calculador\Graficalculador\step_002_Sin_BaseClass\fotos\para enviar\message box from new menu item.jpg[/IMG]
This dialog box was implemented automatically in time of execution of my application by the engine of the framework application of Visual C++.
And from this dialog box I can choose one form or another; but fellows, I don't like the exposed behaviours, sound to me like not to professional.
Id like choosing one form or another by using menmuitems.
[IMG]C:\MyWorks\MY_Visual C++ projects\Graficador_Calculador\Graficalculador\step_002_Sin_BaseClass\fotos\para enviar\menubar items.jpg[/IMG]
I've been searching in different forums and I couldnt find any solution.
The question is: where can I find some information about how to code the menuitem in order to invoke one form or another.
If some fellow can pass to me some code, like a point starting I'll be really thankful.
I haven't to much knowledge in visual C++, that's the reason why I'm posting this question.
Everything that I've got, I've made it with a lot of reading and patience.
If some of you dear comrades are attracted by something from my program will not hesitate to let me know and I'll pass the request.
Kind regards from Juanelo Von Seattle
Well the situation is that I'm developing a application to graph math equations using Visual C++ 6.0.
By the time, I get two forms:
One form used to introduce values to graph math equations of only one variable.
[IMG]C:\MyWorks\MY_Visual C++ projects\Graficador_Calculador\Graficalculador\step_002_Sin_BaseClass\fotos\para enviar\screen and form to graph equations of one variable.jpg[/IMG]
Another form used to introduce values to graph parametric equations.
[IMG]C:\MyWorks\MY_Visual C++ projects\Graficador_Calculador\Graficalculador\step_002_Sin_BaseClass\fotos\para enviar\screenAndFormParametricEquations.jpg[/IMG]
All right, When the application start, appear the menubar IDR_MAINFRAME within main frame window.
After clicking on FILE menu appears the menuitem NEW .
After clicking on NEW appears a little dialog box, below the NEW menuitem, showing the two forms. In this way I can choose which form I want to open.
[IMG]C:\MyWorks\MY_Visual C++ projects\Graficador_Calculador\Graficalculador\step_002_Sin_BaseClass\fotos\para enviar\message box from new menu item.jpg[/IMG]
This dialog box was implemented automatically in time of execution of my application by the engine of the framework application of Visual C++.
And from this dialog box I can choose one form or another; but fellows, I don't like the exposed behaviours, sound to me like not to professional.
Id like choosing one form or another by using menmuitems.
[IMG]C:\MyWorks\MY_Visual C++ projects\Graficador_Calculador\Graficalculador\step_002_Sin_BaseClass\fotos\para enviar\menubar items.jpg[/IMG]
I've been searching in different forums and I couldnt find any solution.
The question is: where can I find some information about how to code the menuitem in order to invoke one form or another.
If some fellow can pass to me some code, like a point starting I'll be really thankful.
I haven't to much knowledge in visual C++, that's the reason why I'm posting this question.
Everything that I've got, I've made it with a lot of reading and patience.
If some of you dear comrades are attracted by something from my program will not hesitate to let me know and I'll pass the request.
Kind regards from Juanelo Von Seattle
↧
↧
Wtl support for atl dll project
I want to add wtl support for atl dll project. I am making Activex Controls.
I searched a lot in internet, but I couldn't find any useful.
Please help me
I searched a lot in internet, but I couldn't find any useful.
Please help me
↧
CHtmlView class. Select text functionality works slowness in big file.
Hello,
Could you please advice, how I can resolve issue with CHtmlView class or replace it.
When I open big *.html file(>200Kb) in my application, "select text functionality" works slowly. I mean "Ctrl+A" and "select text functionality" with left button only in the end of document. Select functionality with left button on the beginning of document works normally always(Even after "select text functionality" worked slowness at the end of page).
I downloaded MFCIE sample from MSDN. "select text functionality" works slowness too in this sample. And "select functionality" works exactly as in my program.
(I built it and start in MSVS 2005. MFCIE Sample: Demonstrates the MFC CHtmlView and CReBar Classes).
In both cases program's class inherit CHtmlView class. And new class uses for open *.html file from my HDD. Program does not handle WM_LBUTTONDOWN event(or pressure Ctrl+A). This process is handled by system in both cases.
I would be grateful for any advice.
Could you please advice, how I can resolve issue with CHtmlView class or replace it.
When I open big *.html file(>200Kb) in my application, "select text functionality" works slowly. I mean "Ctrl+A" and "select text functionality" with left button only in the end of document. Select functionality with left button on the beginning of document works normally always(Even after "select text functionality" worked slowness at the end of page).
I downloaded MFCIE sample from MSDN. "select text functionality" works slowness too in this sample. And "select functionality" works exactly as in my program.
(I built it and start in MSVS 2005. MFCIE Sample: Demonstrates the MFC CHtmlView and CReBar Classes).
In both cases program's class inherit CHtmlView class. And new class uses for open *.html file from my HDD. Program does not handle WM_LBUTTONDOWN event(or pressure Ctrl+A). This process is handled by system in both cases.
I would be grateful for any advice.
↧
CMake unable to build a project when both vs2010 ultimate and express are installed
It insists to look for the express version for building 64bit projects
even though I have re-installed VS2010 ultimate on top of vs2010 express again.
How can I make CMake to look for the ultimate compiler eventually?
Thanks
Jack
even though I have re-installed VS2010 ultimate on top of vs2010 express again.
How can I make CMake to look for the ultimate compiler eventually?
Thanks
Jack
↧
How can i control volume for specific application!!!
I'm about writing code in C++ which i can use to control volume (for example, Google chrome), I added that function to my code, but it control master volume instead of just the application volume:
Do you have any idea how to that ? even if it possible to use HKEY (regedit) or if i can control volume for specific process ?
Thanks
Code:
setChangeVolume(const double & iVolume)
{
HRESULT hr=NULL;
double newVolume = iVolume;
CoInitialize(NULL);
IMMDeviceEnumerator *deviceEnumerator = NULL;
hr = CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_INPROC_SERVER,
__uuidof(IMMDeviceEnumerator), (LPVOID *)&deviceEnumerator);
IMMDevice *defaultDevice = NULL;
hr = deviceEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &defaultDevice);
deviceEnumerator->Release();
deviceEnumerator = NULL;
IAudioEndpointVolume *endpointVolume = NULL;
hr = defaultDevice->Activate(__uuidof(IAudioEndpointVolume),
CLSCTX_INPROC_SERVER, NULL, (LPVOID *)&endpointVolume);
defaultDevice->Release();
defaultDevice = NULL;
// -------------------------
float currentVolume = 0;
unsigned int icurrentVolume = 0;
endpointVolume->GetMasterVolumeLevel(¤tVolume);
hr = endpointVolume->GetMasterVolumeLevelScalar(¤tVolume);
hr = endpointVolume->SetMasterVolumeLevelScalar(static_cast<float>(newVolume), NULL);
endpointVolume->Release();
CoUninitialize();
}
Thanks
↧
↧
DEFINE_ENUM_FLAG_OPERATORS macro
I'm working on a cross-platform library which is supposed to be buildable with MSVC (and always has been, up until now). But after a git update today I'm seeing a lot of errors which seem to boil down to this newly added code fragment:-
I can't find DEFINE_ENUM_FLAG_OPERATORS defined anywhere in the library code - so I'm assuming it's expected to come from MSVC, Unfortunately it isn't in my version (VC8). Is this a macro that's available in more recent versions of MSVC? And if so, can anyone show me what it looks like? Maybe I can just add it locally.
Code:
#ifdef _MSC_VER
# define HB_MARK_AS_FLAG_T(flags_t) DEFINE_ENUM_FLAG_OPERATORS (##flags_t##);
#else
// whatever
#endif
↧
Taskbar not appearing in auto-hide mode when cursor is placed over deskband controls
I've recently written a deskband object using this tutorial http://www.codeproject.com/Articles/...nd-Tray-Notifi
The problem is that taskbar not appearing in auto-hide mode when cursor is placed over deskband controls. I'm using windows 10 and it's interesting that when i restart explorer.exe everything is OK. What's the problem? Is it windows bug? or is it a programming error?
The problem is that taskbar not appearing in auto-hide mode when cursor is placed over deskband controls. I'm using windows 10 and it's interesting that when i restart explorer.exe everything is OK. What's the problem? Is it windows bug? or is it a programming error?
↧
sudoku
I am trying to write a program that will help play Sudoku. It needs to read in the data from a txt file using a get. And follow the letter commands N= new game, A= add character, R= remove d= display board. What I am having difficulty with at the moment is reading the board into a 2d array board. After N it should read in the next characters including the blanks into an array. I can't seem to get the right numbers in the right format. The input will be attached below thanks for any help
Input file
N
145369287
629785431
783412569
567148392
938527 14
214936758
851 74623
492853 76
376291845
D
R 7 7
A 7 7 9
A 7 4 6
A 8 7 1
A 5 7 6
D
N
6892731
921653847
57314 269
154 6972
689271453
742395 81
257834196
19 762538
365 972
D
A 9 9 4
A 1 1 4
A 8 3 4
A 1 9 5
A 9 1 8
A 4 5 8
A 6 7 6
A 3 6 8
A 4 1 3
A 9 5 1
D
N
2 4 63
421
9 6 42
9 7 6
35 28
7 1 5
59 6 8
857
18 3 5
D
A 3 2 4
A 4 1 7
A 8 8 8
A 5 5 5
A 6 9 2
A 3 7 9
A 5 8 9
A 0 4 9
A 3 0 3
A 9 1 0
D
A 2 8 5
A 5 9 7
D
Code:
#include<iostream>
#include<fstream>
#include<iomanip>
using namespace std;
const int MAXCOL = 9;
const int MAXROW = 9;
void dis_board(char arr[][MAXCOL]);
void new_board(char arr[][MAXCOL], char ch, ifstream& in);
int main()
{
char board[MAXROW][MAXCOL];
int row, col, num_ele = 0, num1;
char ch1;
ifstream infile;
infile.open("mp6in.txt");
infile.get(ch1);
while (infile)
{
if (ch1 == 'N')
infile.ignore(10, '\n');
infile.get(ch1);
new_board(board, ch1, infile);
//dis_board(board);
infile.get(ch1);
}
dis_board(board);
}
void dis_board(char arr[][MAXCOL])
{
for (int i = 0; i < MAXROW; i++)
{
for (int j = 0; j < MAXCOL; j++)
cout << arr[i][j] << " ";
cout << endl;
}
}
void new_board(char arr[][MAXCOL],char ch, ifstream& in)
{
for (int i = 0; i < MAXROW; i++)
{
for (int j = 0; j < MAXCOL; j++)
{
in >> (arr[i][j]);
}
}
}
Input file
N
145369287
629785431
783412569
567148392
938527 14
214936758
851 74623
492853 76
376291845
D
R 7 7
A 7 7 9
A 7 4 6
A 8 7 1
A 5 7 6
D
N
6892731
921653847
57314 269
154 6972
689271453
742395 81
257834196
19 762538
365 972
D
A 9 9 4
A 1 1 4
A 8 3 4
A 1 9 5
A 9 1 8
A 4 5 8
A 6 7 6
A 3 6 8
A 4 1 3
A 9 5 1
D
N
2 4 63
421
9 6 42
9 7 6
35 28
7 1 5
59 6 8
857
18 3 5
D
A 3 2 4
A 4 1 7
A 8 8 8
A 5 5 5
A 6 9 2
A 3 7 9
A 5 8 9
A 0 4 9
A 3 0 3
A 9 1 0
D
A 2 8 5
A 5 9 7
D
↧