|
This is the output I get from my program now, but after it ouputs the correct value it says outputs another number like -12323e.6 and then says "Program Complete!" again. How do i get rid of this second output? Im also getting an error message - line [14] conversion from double to float, possible loss of data. Thanks.
#include "stdafx.h"
#include <iostream>
using namespace std;
float CheckCent(float c)
{
if(c>30)
{
c=(c-32)/(1.80); return c;
}
else return c;
}
int _tmain(int argc, _TCHAR* argv[])
{
float myarray[50];
int flag;
flag=1;
int i;
for(i = 0; i < 50 && flag == 1; i++)
{
cout << "Enter Temperature Reading:";
cin >>myarray[i];
cout << "Enter 1 to input more values, 0 to stop";
cin >>flag;
}
cout << "\n\nNumber of elements in the array is: " << i <<endl;
cout <<"\n";
for(int j=0;j<=i;j++)
{
myarray[j]=CheckCent(myarray[j]);
cout <<"The corrected value is: ";
cout <<myarray[j] <<" Celsius";
cout <<"\n\nProgram Complete!\n\n";
}
return 0;
}
|
|
|
|
|
Try this
for(int j = 0; j < i; j++)
instead of this
for(int j = 0; j <= i; j++)
-- modified at 10:22 Monday 9th April, 2007
|
|
|
|
|
I have a Property Sheet, I add 5 page in to the sheet. I want to change page name at runtime.
Please help me.
Thanks a lot,
Papais
|
|
|
|
|
dungpapai wrote: I want to change page name at runtime.
Since a CPropertyPage is nothing but a CWnd , you can use its SetWindowText() method to change its caption.
/ravi
|
|
|
|
|
I have used SetWindowText() at OnInitDialog() function of each pages but it does not success.
Papais
|
|
|
|
|
hi!
I have put two radio. one is singleselect and second is multiselect.
I want to set the click event on radio button for enable/disale Combobox and Listbox control.
for single select on which event of radio button.I have to write the code. Is BN_CLICKED ?
if it is then how can I write?
Please give me some guidline
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
Is there a Win32 API I can call to get the total physical RAM of the computer?
It would also be nice to get "Available physical memory" as well, but that's not really a huge concern. But it probably involves using some awful API like WMI or PDH.
|
|
|
|
|
|
Brilliant. I knew it had to be simple. I think I'll use both GlobalMemoryStatusEx() and GlobalMemoryStatus() to make sure I handle all Windows platforms cleanly.
|
|
|
|
|
hi
I will ask a question but I don't know it is about the subject I wrote.I have a dialog box with an edit box and from this dialog box I created a new dialog box.And in second dialog box I will put many pushbuttons because I want to use it like a keyboard.When I push a button in second dialog box,it shoud write a letter at the edit box in first dialog box and the second dialog box will not be closed when I push the button.I tried many ways but in the first dialog box I coudn't get the knowledge of which button is pushed in second dialog box.How can I do that?
Thanks
|
|
|
|
|
Here's one way:- Add a public method to your first dialog box, that appends a letter to the edit control. For example:
void CFirstDlg::TypeLetter
(CString theLetter)
{
CString strText;
CEdit* pEditBox = GetDlgItem (IDC_EDIT_BOX)
pEditBox->GetWindowText (strText);
strText += theLetter;
pEditBox->SetWindowText (strText); <code>
int nLen = strText.GetLength();
pEditBox->SetSel (nLen, nLen, TRUE); <code>
}
- When you create your second dialog, pass it a pointer to the first dialog box. In the button handlers of your second dialog box, "send" the typed keystroke to the first dialog box. For example:
void CSecondDlg::TypeD()
{
m_pFirstDlg->TypeLetter ("D");
}
/ravi
|
|
|
|
|
Thanks
But I am beginner and I couldn't understand some parts.
First of all is this program will write the letter to first dialog box at the same time when I pushed the button in the second dialog box?Which part of the program provide this?And lastly,where I am declaring m_pFirstDlg?
Thanks again.
|
|
|
|
|
Which part of code is hard for you?
|
|
|
|
|
I tried a similar code in my project but I couldn't achieve.I declare a new object in second dialog box like;
void CSecondDlg::TypeD()
{
CFirstDlg firstDlg;
firstDlg.TypeLetter("d");
}
The problem is that for me I think the method in second dialog box is creating a new object which is different from the First dialog box own object.And when I add a letter in second dialog it is directly adding the letter to its own object so I couldn't see the letter in first dialog box(is it true?I am only thinking and I am not experienced).Maybe I don't know how thay are communicate with each other.
|
|
|
|
|
Do you want to send some values of a dialog to another dialog,if yes you can use of this line
CFirst *m_First=(CFirst*)GetParent();
<code>m_First->m_str;</code> or <code>m_First->yourcontrol</code>
|
|
|
|
|
iayd wrote: is this program will write the letter to first dialog box at the same time when I pushed the button in the second dialog box?
Yes.
iayd wrote: Which part of the program provide this?
I'm not sure I understand your question.
iayd wrote: where I am declaring m_pFirstDlg?
m_pFirstDlg is declared in the second dialog box and is a pointer to the first one. When the first dialog box creates the second one, it should pass a pointer to itself to the 2nd dialog box. That pointer is stored in the second dialog box's member variable m_pFirstDlg . Alternatively (as has WhiteSky has pointed out), the 2nd dialog box can get at the first dialog box by calling GetParent() , since it (the 2nd dialog box) is the child of the first one.
/ravi
|
|
|
|
|
Thanks to ravi and WhiteSky.
These answers solved my problem.
|
|
|
|
|
How to restrict the user to collapse the items in a tree control, it should always be expanded mode.
|
|
|
|
|
You can handle TVN_ITEMEXPANDING and return TRUE if the node is one you don't want to collapse
|
|
|
|
|
|
Hi everyone, I am working on a project for a C++ course, and I am running into a compile error that I can't figure out how to fix. It seems to be telling me that I am using a class member that is an undeclared identifier. As far as I can tell, it has been declared.
Here is the class declaration:
class Student
{
public:
/* Constructors and Destructor */
Student();
virtual ~Student();
Student(std::string first, std::string last, int SNum);
/* Getters and Setters */
std::string getFirstName(void);
void setFirstName(std::string newName);
std::string getLastName(void);
void setLastName(std::string newName);
int getStudentNum(void);
void setStudentNum(int newNum);
std::vector<std::string> getGradeList(void);
void setGradeList(std::vector<std::string> &GList);
private:
std::string FirstName;
std::string LastName;
int StudentNum;
std::vector<std::string> GradeList;
};
And this is the code that is giving the problems at compile-time:
void setGradeList(std::vector<std::string> &GList)
{
GradeList = GList;
}
Build error:
students.cpp(62) : error C2065: 'GradeList' : undeclared identifier
So, this is driving me crazy, and any help would be greatly appreciated!
Thanks in advance!
|
|
|
|
|
all_in_flames wrote:
students.cpp(62) : error C2065: 'GradeList' : undeclared identifier
Because GradeList() is not a member of class Student .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
You left out the class name in the function header:
void <font color=red>Student::</font>setGradeList(std::vector<std::string>& GList)
|
|
|
|
|
You are a C++ gawd. Thanks again Mike!
|
|
|
|
|
Hello.
I am trying to write a program that stores a LOT of bitblits (a lot of images) in memory for later processing. I want to capture some motion on the screen so I'm bitblitting 30 times a second to an array of HBITMAPS. Before blitting I'm doing a CreateCompatibleBitmap on every HBITMAP, but it returns error code 8 ERROR_NOT_ENOUGH_MEMORY when it reaches the 145 element in the HBITMAP array. How can this be?
I'm not trying to display motion, I'm trying to capture motion. Imagine you have a game running; I want to capture 5 minutes of "screenshots", let's say 30 screenshots pr second; 30 bitblits pr second. I want to do some processing on those images - example do some edge detection. I can't do it in real-time because I would have to do the edge detection between each image capture, which delays the next image (we need 30 pr second). And I can't save them on disk since writing 30 bmps pr second is way too slow. So naturally I have to capture all the images in memory, then process them afterwards. Get where I am going?
I don't know if bitblt is the most optimal way of doing this. The game I want to capture from is OpenGL, and I want to capture the game action without hooking anything in the game (so naturally I can't hook the opengl functions and get images directly from the buffers, right?) - Do you know other ways of capturing 30 images per second and storing them than using bitblt etc?
I'm still wondering why windows limits me to a certain amount of HBITMAPS at a time though - My program only uses 1,448kb memory when the 145 HBITMAPS are Created so I'm definitely not out of memory. Perhaps it's a number restriction?
Any help would be greatly appreciated!
|
|
|
|