|
Consider declaration :
std::string s1=("command:userID:Password");
I want to separate s1 into three sub std::strings by searching colon ":"
How can i do so ???
|
|
|
|
|
|
Can't get this program to excute.I will be very happy if I can get help with it.I am trying to evaluate the file layout to determine the location and size of the following fields so it would look something like this: 10/06/99,3022362451,1214523251,9:00,23:00,9:00
Date
Origination Number
Destination Number
Call Durtion
Time of Call
Cost of Call
Origination Place(City,State)
Destination Place(City,State)
#include<stdio.h>
void main (void)
{
char student_name [50];
char student_class [50];
char student_id;
char course_name [50];
char student_address[50];
double quiz_grade,quiz_grade1,quiz_grade2,quiz_grade3;
double exam_grade,exam_grade1,exam_grade2,exam_grade3;
double daily_grade,daily_grade1,daily_grade2,daily_grade3;
double
assignment_grade,assignment_grade1,assignment_grade2,assignment_grade3;
double total_points;
}
student_rec student_data [3];
for(i=0.i<3,i++)
{
printf("/n Enter student name");
gets (student_data.student_name);
typedef struct student_rec;
printf("\n Enter class name");
gets(students_data.class_name);
printf("\n Enter student address");
gets(students_data.student_address);
printf("\n Enter class name");
gets(students_data.student_id);
printf("\n Enter Daily grade:");
gets(students_data.Daily_grade1);
printf("\n Enter Daily grade 2:");
gets(students_data.Daily_grade2);
printf("\n Enter Daily Grade 3:");
gets(students_data.daily_grade3 ;
daily_grade= daily_grade1+daily_grade2+daily_grade3/3*.10
printf("\n Enter quiz grade:");
gets(students_data.quiz_grade1);
printf("\n Enter quiz grade 2:");
gets(students_data.quiz_grade2);
printf("\n Enter quiz Grade 3:");
gets(students_data.quiz_grade3 ;
quiz_grade=quiz_grade1+quiz_grade2+quiz_grade3/3*.10
printf("\n Enter Assignment grade:");
gets(students_data.Assignment_grade1);
printf("\n Enter Assignment grade 2:");
gets(students_data.Assignment_grade2);
printf("\n Enter Assignment Grade 3:");
gets(students_data.Assignment_grade3 ;
Assignment_grade=Assignment_grade1+Assignment_grade2+Assignment_grade3/3*.30
printf("\n Enter exam grade:");
gets(students_data.exam_grade1);
printf("\n Enter exam grade 2:");
gets(students_data.exam_grade2);
printf("\n Enter exam Grade 3:");
gets(students_data.exam_grade3 ;
exam_grade=exam_grade1+exam_grade2+exam_grade3/3*.50
total=Assignment_grade+daily_points+quiz_point+exam_points
gets(student_data.total);
}
Can anyone help me finish it.
awillie
|
|
|
|
|
void main is not valid C++, even if your compiler does not know it.
I dunno what gets is, but printf is a C function. I also cannot see what you have included. If you use C++ ( i.e. use iostreams instead ), then reading values from a comma delimited string is easy, just use getline and make the second parameter a ','.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
I think you have misplaced }
double total_points;
}
should be at the bottom
gets(student_data.total);
}
}
BTW, one debugging technique is to remove everything and slowly add code that works until you locate the bug. So try to get
void main ()
{
}
to compile and then proceed from there.
Todd Smith
|
|
|
|
|
One way is to create an ActiveX control which can be put on a dialog box
|
|
|
|
|
I mean that I dont want the graphic to be in CView anymore. I just want it to be in a dialog box. Please anybody
|
|
|
|
|
You can do it in the dialogs OnPaint event as shown below. Most of this was generated by the wizard when I started the project. I moved two lines to the top of the function, and added two lines to the "else" clause.
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CTry1Dlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rect;
if (IsIconic())
{
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
GetClientRect(&rect);
dc.DrawText("Hello World",11,rect,DT_CENTER );
}
}
|
|
|
|
|
Which is the preferred way to terminate the modal dialog? I notice that no matter which one I use, the lines of code following it do get executed, even though the dialog itself has vanished!
i.e.
<pre>MYClass::OnOK()
{
CDialog::OnOK();
CMyDlg myDlg;
myDlg.DoModal();
}
</pre>
The original dialog vanishes and the second one gets spawned. This hapens even with EndDialog(IDOK).
That seems peculiar to me. I'd have thought that if the dialog itself is terminated, the subsequent statements would never be reached....
Thnaks,
ns
|
|
|
|
|
EndDialog() is a Win32 call. Its argument is the return value of DoModal() . CDialog::OnOK() does the same thing as EndDialog(IDOK) . Also CDialog::OnCancel() does the same thing as EndDialog(IDCANCEL) .
EndDialog() and CDialog::OnOK() are just function calls. If you want execution to end, you need to stick in a return; after the call.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
EndDialog() does not destroy the dialog immediately. It destroys the dialog at the end of the current message handler.
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
nss wrote:
Which is the preferred way to terminate the modal dialog?
I just realized my thesis didn't include an answer to your question. I suggest using CDialog::OnOK() or CDialog::OnCancel() , unless you need to return a custom return value, in which case use EndDialog() .
You typically do the latter when you have more than one button that ends the dialog, and you want to inform the caller which button the user clicked. For example:
CMyDialog dlg (this);
long nStatus = dlg.DoModal();
switch (nStatus) {
case IDOK:
doOkHandling();
break;
case IDCANCEL:
doCancelHandling();
break;
case ID_SomethingElse:
doSomethingElseHandling();
break;
default:
ASSERT (FALSE);
break;
}
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I wonder if there's a way of making Windows not reallocate the memory for CArray objects without using CArray::SetSize(int) function?
I mean I want to create a dynamic array of relatively large objects and I need pointers to the elements. When I add a new element with CArray::Add function, the operating system reallocates the memory and my pointers to the previous elements become invalid. Is there any way of 'fixing' the addresses of the elements?
|
|
|
|
|
Space Ace wrote:
When I add a new element with CArray::Add function, the operating system reallocates the memory and my pointers to the previous elements become invalid.
Not really. I suspect there are problems in your code. Can you post a sample?
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
If it's anything like vector you should be able to pass an initial size into the constructor, then it won't reallocate until you go over that size. That naturally removes one of the main advantages of a dynamic array.
By the way, CArray is absolute trash, you should ditch it and use vector instead.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
Hello, the codegurus around the world.;)
Generally speaking, we can define Find function to find CArray index.
So, without the pointer of CArray, we can find any index with some
key value.
This means if we derived some class from CObject, we can insert
this class in CArray template.
(Or, I misunderstand something? )
Please, don't send me your email about your questions directly.
Have a nice day!
Sonork - 100.10571:vcdeveloper
-Masaaki Onishi-
|
|
|
|
|
Store the index instead of the pointer. You can always get the pointer back.
Joel Lucsy (jjlucsy@ameritech.net)
|
|
|
|
|
I see that This method is used by class CWinApp to translate window messages before they are dispatched to the Windows CE TranslateMessage and DispatchMessage functions from the MSDN but what in the world is the meaning of translate in this case? I cant find a technical definition of translate anywhere....
Thanks,
ns
|
|
|
|
|
You're reading the documentation for the CE version. Here's the Win32 doc:
The TranslateMessage function translates virtual-key messages into character messages. The character messages are posted to the calling thread's message queue, to be read the next time the thread calls the GetMessage or PeekMessage function.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Thanks much! BTW I'm having a heck of a time with overriding the OnOK() and bad behavior (see my thread). I'm going to have to use the pretranslate msg I've tried and tried! If the OnOK() is blank (no base handler) all is well. But try to get rid of the OK button and it behaves bizzaerely...enter dismisses agin!
|
|
|
|
|
I'm having no luck preventing the dismissal of my modal dlg with the Enter key press by overriding the OnOk of the class. SO I am going to go with pretranslatemessage. Question before I invest time in the UI of the modal dlg:
There wil be a listcontrol on it and the user chooses an item which gets written to a textbox. associated with this textbox is another CEdit where the user enters a value. then I press a "Done" button which calls EndDialog(nRet);
Will pretranslate message interfere with any of these functionalities?
BOOL CLog::PreTranslateMessage(MSG* pMsg)
{
if ((pMsg->message == WM_KEYDOWN))// && (pMsg->hwnd == m_hWnd))
{
if (pMsg->wParam == VK_RETURN)
{
return TRUE;
}
}
return CDialog::PreTranslateMessage(pMsg);
}
Thanks,
ns
|
|
|
|
|
OnOK() is the way to do this. If you don't want the dialog to close simply don't call the parent class OnOK().
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
|
Really, I did - my OnOK for the OK button is empty and Enter is ignored. But I dont want that button around. I want my own button that does some stuff then exits. So if I make the default Ok button invisible or delete it after making sure that OnOK() is blank (no CDialog::OnOK() being callled in it), the Enter dismisses it again! I cant keep a useless OK button around, and deleting it brings back the bad behavior.....
Thanks,
ns
|
|
|
|
|
You also need to add a new button (see my previous reply) with id IDC_DONE . That button's handler should eventually call CDialog::OnOK() .
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|