|
The result of that part of the condition would be the same as
static_cast<bool>(system[index].name)
The string literal will be evaluated but the result of the comma operator is always the leftmost argument. (You probably know that, but I thought I should offer an explanation for less experienced readers)
My guess is this was supposed to be a string comparison. Not that it makes the condition look any better...
Oh, and btw., I know that '??! ' is the trigraph for '| ', but I'm not familiar with '?!? '. Typo?
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
It's like a long paragraph with no commas or punctuation.
cheers
Chris Maunder
|
|
|
|
|
I have made a program with Outlookbar Class and a clistview class now, i'd like when i click in the Outlookbar automatically the view will take the focus. I have tried with SetFocus(). but nothing.
Can you indicate me the correct procedure?
i start with this line to geto pointer to the view
CView* pView = (CView*)GetActiveView();
It will not take you many time, so thanks in advance.
Giovanni
|
|
|
|
|
Hi everyone;
can someone help me with the program im doing..
1. i need to add and save student record without using database or text file.
2. view/search record.. that can be sort by category
3. edit record.
4. delete record
how am i suppose to do it???
hope someone could help..
|
|
|
|
|
Robin Percival Vibar wrote: how am i suppose to do it??? Yes, that's a good question: if you don't want to loose your changes every time your program exits then you have to use permanent storage, that is the hard disk (or another persistent medium like, for instance, flash memory of pen drives). Since you don't want to use a text file, I suppose a binary file is OK for you. You could design your own protocol or use object serialization. If you are using MFC , then you are lucky, since such framework provides good support to serialization, see "Serialization in MFC"[^].
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
Hello Everybody,
I'm working on a simple C++ Project in VS 2013 Express. I'm trying to implement a TLS Callback function into a simple prog. What I want to do in future is to check for any present debuggers before the main (entrypoint) is called (...I know that most debuggers can handle TLS).
Here is my code so far and it works:
#include <windows.h>
#include <stdio.h>
using namespace std;
void WINAPI TLSCallback(PVOID DllHandle, DWORD dwReason, PVOID Reserved)
{
MessageBox(0, L"TLS Callback before main.", L"TLS CallBack", 0);
}
#ifdef _M_IX86
#pragma comment (linker, "/INCLUDE:__tls_used")
#pragma comment (linker, "/INCLUDE:__xl_b")
#else
#pragma comment (linker, "/INCLUDE:_tls_used")
#pragma comment (linker, "/INCLUDE:_xl_b")
#endif
#ifdef _WIN64
#pragma const_seg (".CRT$XLB")
const
#else
#pragma data_seg (".CRT$XLB")
#endif
EXTERN_C
{
PIMAGE_TLS_CALLBACK _xl_b = TLSCallback;
#pragma data_seg ()
#pragma const_seg ()
}
int main(int argc, char* argv[])
{
printf("Hello World from main()!");
getchar();
return 0;
}
However, the really strange thing (at least to me) is, that if I switch in VS 2013 Express from Debug Configuration to Release Configuration and compile the project, AntiVir pops up with a message like "TR/Crypt.XPACK.Gen" found in compiled EXE. O.k. since TLS is also used by maleware I can basically understand that AntiVir doesn't like such things, but why does it not happen in Debug Configuration? Is there any way that it also would work in Release Configuration (Linker Options etc.?) ?
modified 4-Oct-14 5:22am.
|
|
|
|
|
hey guys, can I ask for help.
can you guys help me with the algorithm/code for quine mccluskey method on C/C++.
i kinda having trouble with the algorithm and I need to provide the code on Oct 9 for my CS class.
please do help me with my machine problem
thank you and God bless.
|
|
|
|
|
Reuben Cabrera wrote: i kinda having trouble with the algorithm... And that trouble would be?
Reuben Cabrera wrote: please do help me with my machine problem Help is a two way street. What have you done thus far?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
im already at converting the decimal # to binary. but the problem is the output should be like as a whole. i saw other programs converting decimal to binary and they just printed the remainder in reverse. my plan is to multiply the first digit to 10^0 then the next is by powers of 10 so when I add it i will have a whole number.
|
|
|
|
|
and quine mccluskey method would require grouping the minterms according to the # of 1's in their binary form. how do you do that?
then printing the final output as wxyz w'x' etc.
|
|
|
|
|
Reuben Cabrera wrote: I need to provide the code on Oct 9 for my CS class. And you think submitting someone else's code and claiming it as your own is a good idea?
|
|
|
|
|
Dear, you are sooooooooooooo old school...
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
Oh you.
|
|
|
|
|
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
int convert(int);
main()
{
int var,x,y,number,number2;
int minterms[x],minterm[y];
printf("=========QUINE MCCLUSKEY METHOD========");
printf("\nHOW MANY VARIABLES DOES THE FUNCTION HAVE:?");
scanf("%d",&var);
printf("\nHOW MANY MINTERMS?:");
scanf("%d",&number);
number2=number;
for(x=0;number2!=0;number2--)
{
printf("\nENTER MINTERM:");
scanf("%d",&minterms[x]);
x++;
}
x=0;
y=0;
while(number!=0)
{
minterm[y]=convert(minterm[x]);
x++;
y++;
}
y=0;
while(number!=0)
{
printf("\n %d",minterm[y]);
number--;
y++;
}
}
int convert(int a)
{
int quot,binarynumber[100],i=1,sum=0;
int multi;
quot=a;
while(quot!=0)
{
binarynumber[i++]=quot%2;
quot= quot/2;
if(i==1)
{
sum=sum + (binarynumber[i++] * 1);
}
else
sum = sum + (binarynumber[i++] * multiplier);
}
return sum;
}
|
|
|
|
|
im not submitting someone else's code. i just need help. that's all.
|
|
|
|
|
Then you need to explain clearly what help; we cannot guess.
|
|
|
|
|
ok. so the binary form is stored in the string. and the i will make a for loop that will count the number of 1's in the binary form of each entered minterms. my problems is how do I group together the minterms with the same number of 1's cause i need to compare 2 different groups later.
|
|
|
|
|
I've created a new dialog in my MFC dialog based application. the new dialog contains 5 control buttons.
the following happens and I don't understand why?
(buttonX is any button).
1. click on buttonX. (result ok, OnBnClicked message is sent)
2. click on on any place of the application, but not on the dialog. (removing focus from dialog)
3. click again on buttonX (FAILED, OnBnClicked message is NOT sent). but if instead I click on any other button in the dialog (result ok, OnBnClicked message is sent).
and when I do:
1. ...
2. ...
3. click on the dialog area just to set focus on the dialog again
4. click again on buttonX. (result ok, OnBnClicked message is sent)
(*) I need to do step 3 only if I want to click again on the buttonX! why??
I think it related to SetFocus() but I m not sure how.
the buttons IDC are: IDC_BACK_MEDIA_PRESS_BUTTON 1180 IDC_TOOLS_LEFT_RIGHT 1024 IDC_MEDIA_FOREWARD_BUTTON 1103 IDC_MEDIA_BACKWARD_BUTTON 1104 IDC_TOOLS_HOOD_BUTTON 2346
the dialog properties is:
IDD_TOOLS_DIALOG DIALOGEX 0, 0, 51, 218 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Tools" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN PUSHBUTTON "Media &Foreward",IDC_MEDIA_FOREWARD_BUTTON,7,79,37,36,BS_MULTILINE PUSHBUTTON "&Media &BackWard",IDC_MEDIA_BACKWARD_BUTTON,7,43,37,36,BS_MULTILINE PUSHBUTTON "Back Media Press",IDC_BACK_MEDIA_PRESS_BUTTON,7,127,37,36,BS_MULTILINE | NOT WS_VISIBLE PUSHBUTTON "Hood",IDC_TOOLS_HOOD_BUTTON,7,7,37,36 PUSHBUTTON "Left Right",IDC_TOOLS_LEFT_RIGHT,7,175,37,36 END
I've tried different style like, tool windows, overlapped, popup. it happens in all the cases.
Thanks for the help.
.h
<pre>
class CToolsDlg : public CBDialog
{
DECLARE_DYNAMIC(CToolsDlg)
public:
CToolsDlg(CWnd* pParent = NULL); // standard constructor
virtual ~CToolsDlg();
CToolTipCtrl m_ToolsTips;
// Dialog Data
enum { IDD = IDD_TOOLS_DIALOG };
protected:
virtual void OnCancel();
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
CMFCButton m_HoodButton;
CMFCButton m_MediaForewardButton;
CMFCButton m_MediaBackwardButton;
CMFCButton m_LeftRightButton;
virtual BOOL OnInitDialog();
virtual BOOL PreTranslateMessage(MSG* pMsg);
afx_msg void OnTimer(UINT_PTR nIDEvent);
afx_msg void OnBnClickedCancel();
afx_msg void OnBnClickedToolsHoodButton();
afx_msg void OnBnClickedMediaForewardButton();
afx_msg void OnBnClickedMediaBackwardButton();
afx_msg void OnBnClickedLeftRightButton();
afx_msg void OnBnClickedBackMediaPressButton();
};
.cpp
IMPLEMENT_DYNAMIC(CToolsDlg, CBDialog)
CToolsDlg::CToolsDlg(CWnd* pParent /*=NULL*/)
: CBDialog(CToolsDlg::IDD, pParent)
{
}
CToolsDlg::~CToolsDlg()
{
}
void CToolsDlg::DoDataExchange(CDataExchange* pDX)
{
CBDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_TOOLS_HOOD_BUTTON, m_HoodButton);
DDX_Control(pDX, IDC_MEDIA_FOREWARD_BUTTON, m_MediaForewardButton);
DDX_Control(pDX, IDC_MEDIA_BACKWARD_BUTTON, m_MediaBackwardButton);
DDX_Control(pDX, IDC_TOOLS_LEFT_RIGHT, m_LeftRightButton);
}
BEGIN_MESSAGE_MAP(CToolsDlg, CBDialog)
ON_WM_CLOSE()
ON_WM_DESTROY()
ON_WM_TIMER()
ON_BN_CLICKED(IDC_TOOLS_HOOD_BUTTON, &CToolsDlg::OnBnClickedToolsHoodButton)
ON_BN_CLICKED(IDC_MEDIA_FOREWARD_BUTTON, &CToolsDlg::OnBnClickedMediaForewardButton)
ON_BN_CLICKED(IDC_MEDIA_BACKWARD_BUTTON, &CToolsDlg::OnBnClickedMediaBackwardButton)
ON_BN_CLICKED(IDC_TOOLS_LEFT_RIGHT, &CToolsDlg::OnBnClickedLeftRightButton)
ON_BN_CLICKED(IDC_BACK_MEDIA_PRESS_BUTTON, &CToolsDlg::OnBnClickedBackMediaPressButton)
END_MESSAGE_MAP()
// CToolsDlg message handlers
BOOL CToolsDlg::OnInitDialog()
{
CBDialog::OnInitDialog();
// Window position
//////////////////////////////////////////////////////////////////////////
CMainFrame* mf = (CMainFrame*)AfxGetMainWnd();
RECT MFwinRect;
RECT ThiswinRect;
CWnd* fv = mf->m_wndSplitter.GetView( mf->m_wndSplitter.GetCurrentViewIndex(0,0) );
fv->GetWindowRect(&MFwinRect);
GetWindowRect(&ThiswinRect);
MoveWindow(
MFwinRect.right - (ThiswinRect.right - ThiswinRect.left) - 14, // X
MFwinRect.top + 14, // Y
(ThiswinRect.right - ThiswinRect.left), // nWidth
(ThiswinRect.bottom - ThiswinRect.top) ); // nHeight
// Set controls state
//////////////////////////////////////////////////////////////////////////
m_ToolsTips.Create(this);
m_ToolsTips.AddTool(&m_HoodButton, TOOLTIP_HOOD_BUTTON);
m_ToolsTips.AddTool(&m_MediaForewardButton, TOOLTIP_MEDIA_FOREWARD_BUTTON);
m_ToolsTips.AddTool(&m_MediaBackwardButton, TOOLTIP_MEDIA_BACKWARD_BUTTON);
m_ToolsTips.AddTool(&m_LeftRightButton, TOOLTIP_LEFT_RIGHT_BUTTON);
m_ToolsTips.SetDelayTime(1000);
m_ToolsTips.Activate(BARAK_PREFS->m_Params.m_bShowToolTips);
// Main timer loop (no need for now)
// SetTimer( 1, 1000, NULL );
return TRUE;
}
BOOL CToolsDlg::PreTranslateMessage(MSG* pMsg)
{
m_ToolsTips.RelayEvent(pMsg);
return CBDialog::PreTranslateMessage(pMsg);
}
void CToolsDlg::OnCancel()
{
// When closing the window, destroy it and not only hide (its a floating window).
DestroyWindow();
}
void CToolsDlg::OnTimer(UINT_PTR nIDEvent)
{
CBDialog::OnTimer(nIDEvent);
}
void CToolsDlg::OnBnClickedToolsHoodButton()
{
...
}
void CToolsDlg::OnBnClickedMediaForewardButton()
{
...
}
void CToolsDlg::OnBnClickedMediaBackwardButton()
{
...
}
void CToolsDlg::OnBnClickedLeftRightButton()
{
...
}
void CToolsDlg::OnBnClickedBackMediaPressButton()
{
...
}
|
|
|
|
|
Which button is it that is doing this behavior? I don't see any button called "buttonX".
Or do all the buttons show this behavior?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hello Richard, "buttonX" applies to all buttons.
|
|
|
|
|
I have following code
int nSize = 100;
unsigned char* pBuffer;
pBuffer = new unsigned char(nSize);
and I tried to clean it by
delete[] pBuffer;
but seems not working ... I have done wrong ?
modified 2-Oct-14 8:50am.
|
|
|
|
|
I know what: I replaced "(" by "[" in
pBuffer = new unsigned char(nSize);
ex
pBuffer = new unsigned char[nSize];
|
|
|
|
|
I found the following program that count the number of words within a phrase but I don't understand the
initial code defined on the int main :
" int argc,const char * argv[]
just want learn. thanks
--------------------------------------
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
// ask the user to enter a string
cout << "Enter a string: ";
// save the string entered by the user
string input;
getline(cin, input);
int numberOfWords = 0;
// loop through the input and count all the spaces
int inputLen = (int)input.length();
for (int i=0; i<inputLen; i++) {
char current = input.at(i);
if (isspace(current)) {
numberOfWords++;
}
}
// in case there were words, and not empty string, remember that there's always
// one space less than the actual number of words
if (numberOfWords > 0) {
numberOfWords++;
}
// print the number of words
cout << "\nNumber of words = " << numberOfWords << endl;;
return 0;
}
|
|
|
|
|
argc = arg count
*argv[] = an array of argc number of strings.
Consider the following program:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int i;
for(i=0; i<argc; i++)
printf("Argument index %d: %s\n", i, argv[i]);
return 0;
}
When I call the program from the command line like so:
argcdemo arg1 arg2 -someFlag -somethingElse
I get the following output:
Argument index 0: argcdemo
Argument index 1: arg1
Argument index 2: arg2
Argument index 3: -someFlag
Argument index 4: -somethingElse
So as you can see, the first one takes the name of the program as invoked, the others get a string from the command line, where each string is separated by a space. Or more simply, the argc will always be at least 1,since you have to specify the name of the program to run. Any subsequent arguments will increment argc and have their values added to the argv array.
"When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down 'happy'. They told me I didn't understand the assignment, and I told them they didn't understand life." - John Lennon
|
|
|
|
|
Google is your friend. See for instance: "argc and argv"[^].
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|