|
Have you tried:
void main( void )
{
std::cout << "This is my genetic algorithm scheduling project for university." << endl;
std::cout << "I have learned a lot from it." << endl;
}
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
hello,
i have a working vc++ application(few kilobytes) which i want to run as a service. please guide me how to do this ? is there any way to create an installer for it ?
btw thanks
rahul
|
|
|
|
|
|
Madhu Nair wrote: How to: Create Windows Services[^] (C++ Programming)
Sorry Madhu, but i don't think it gives any good light on what the question is
HARSH
Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.
|
|
|
|
|
Bing for the program "srvany"
--Mike--
Dunder-Mifflin, this is Pam.
|
|
|
|
|
rahuljin wrote: i have a working vc++ application(few kilobytes) which i want to run as a service. please guide me how to do this ?
See here, here, here, here, and here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
My object is to read the text file containing the name and ages of the students, character by character and then store them in a structure. (For test purpose I want to store just one record) I wrote the following code but it is giving an error "aggregate'main():: record r' has incomplete type and cannot be defined". Why is this?
main()
{
char ch[80],alpha[100],data[80];
int n=0,sno=2;
FILE*fp;
fp = fopen("records.txt","rb");
if(fp == NULL)
{
puts("Cannot open file");
exit(1);
}
struct record;
{
char name[80];
int age;
};struct record r;
while(1)
{
ch[n]=fgetc(fp);
if (isdigit(ch[n])&& ch[n-1]==32)
{r.name[n]=ch[n-1];
n=n+1;
if (n==1)
break;
}
}
fclose(fp);
}
|
|
|
|
|
Razanust wrote: struct record;
{
char name[80];
int age;
};struct record r;
1. Declare the struct outside the main function
2.
struct record; <--
{
char name[80];
int age;
};
Remove the semicolon while declaring the struct.
|
|
|
|
|
Razanust wrote: struct record;
remove the ';' there and see.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
Wow! Your code has so many problems. For example, how exactly does the while() loop end?
Razanust wrote: My object is to read the text file containing the name and ages of the students, character by character and then store them in a structure.
See here.
You could also use fscanf() like:
fscanf(fp, "%s %d", r.name, &r.age);
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
hi
i need an edit ctrl for entering numerical values. sometimes these values must lie in a specified range. otherwise, i want to warn the user by changing the edit-box color.
i derived a class from CEdit for this purpose and tried to put the code in the CtlColor:
HBRUSH MyEdit::CtlColor(CDC* pDC, UINT nCtlColor)
{
if (d_chars==decimalChars)
{
CString s;
GetWindowText(s);
USES_CONVERSION;
int val=atoi(T2A(s));
if (val<d_minVal || val>d_maxVal)
{
pDC->SetTextColor(RED);
pDC->SetBkColor(YELLOW);
}
}
return NULL;
}
i don't need to change the default brush used for painting the ctrl, so i return NULL. but this doesn't work. i tried returning a valid handle to a brush i created, but i could at most change the background color, not the text color.
what's the problem?
what's the best solution?
thx
|
|
|
|
|
ilostmyid2 wrote: derived a class from CEdit for this purpose
This is not correct.
WM_CTLCOLOR is sent to the parent window.
So you should be handling OnCtlColor of the parent dialog.
In that, check if the message is for your particular edit control and then do pDC->SetTextColor .
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
MyEditBox::MyEditBox()
{
m_brush = NULL;
itemData = NULL;
}
MyEditBox::~MyEditBox()
{
delete m_brush;
}
BEGIN_MESSAGE_MAP(MyEditBox, CEdit)
ON_WM_CTLCOLOR_REFLECT()
END_MESSAGE_MAP()
bool MyEditBox::SetColorScheme(COLORREF brushColor, COLORREF bgTextColor, COLORREF fgTextColor)
{
delete m_brush;
m_brush = new CBrush(brushColor);
bgc = bgTextColor;
fgc = fgTextColor;
Invalidate();
UpdateWindow();
return (m_brush != NULL);
}
void MyEditBox::ResetColorScheme()
{
delete m_brush;
m_brush = NULL;
Invalidate();
UpdateWindow();
}
HBRUSH MyEditBox::CtlColor(CDC* pDC, UINT nCtlColor)
{
if (m_brush == NULL)
return NULL;
pDC->SetTextColor(fgc);
pDC->SetBkColor(bgc);
return (HBRUSH)m_brush->GetSafeHandle();
}
|
|
|
|
|
I have created an MFC app as a SDI supporting doucment/view architecture. The main classes are: CMainFrame, CView, and CDocument. In my app I want to dynamically create a CListView when the user select a menu item. I've added CListView class to my project. In my OnInitialUpdate() I'm doing InsertColumn() calls and in OnUpdate() I'm doing InsertItem() and SetItemText(). When a menu item is select I am basically set a point to a new CListView object. What is not working is that nothing is being displayed on the screen !!! I know once the memory is allocated for the new CListView object I need to call Create() function. Don't know what I need to pass or how to link this to my CView class so that it is acutally displayed. Please help. I have not seen any good examples on dynamically creating a CListView object.
|
|
|
|
|
|
Thank for you the links. I changed my app to use multiple views in SDI. Good examples.
|
|
|
|
|
My object is to fill the buffer first and then make it empty. But the 'sizeof' command is returning the value '1', whatever input i give to it. Why? The code is mentioned below.
#include<stdio.h>
#include<conio.h>
main()
{
char dec;
static char ch[100];
int n=0,i,p,c,count;
while(1)
{
ch[n]=getche();
n=n+1;
if ( ch[n-1]=='\r')
break;
}
count=sizeof(ch[100]);
printf("%ld",count);
printf("Your name is");
for (c=0;c<count;c++)
{
printf(" %c",ch[c]);}
printf("\n\nWant to delete the array?");
dec=getche();
if (dec=='y')
{
for (i=0;i<99;i++)
ch[i]=0;
}
if (dec=='y')
{
for(p=0;p<99;p++)
printf("%c",ch[p]);
}
}
|
|
|
|
|
Razanust wrote: But the 'sizeof' command is returning the value '1'
It returns 1 and that is correct, because this is the size of a char type.
If you need the count of the elements in array, you have to use _countof macro -> here.[^]
This form here: count = _countof(ch) will always return 100, because you actualy allocated memory for 100 elements on the stack. But note that the variable "n" from your code holds the count of the characters.
Razanust wrote: count=sizeof(ch[100]);
Also note that your use of sizeof is wrong. If you need the size of an array in bytes, than you must change it to: sizeof(ch) .
Best wishes!
Nuri
modified on Tuesday, June 30, 2009 3:07 PM
|
|
|
|
|
If by 'whatever input' you mean the number you put in the square brackets for ch[100], I think this is because ch[n] is always going to be a pointer. It's equivalent to
<br />
char *ch = (char*)malloc(sizeof(char) * n);<br />
then sizeof(ch) will always be 1 because it's pointing to the start of your array. In C, you sort of always have to keep track of the size of your arrays manually.
|
|
|
|
|
thebeekeeper wrote: because ch[n] is always going to be a pointer
Nope.
ch is a pointer, ch[n] is one character out of an array of characters, that is why its size is 1.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
ha! I forgot that [] are for indexing into arrays!
|
|
|
|
|
OK - that's not how sizeof works - it tells you the size of a type, either via the typename ('sizeof (char)') or a compile-time static expression ('sizeof (3 * 4.0)'). The WIkipedia entry[^] is quite accurate.
I presume you know you can use n to tell you how many characters have been entered...
Razanust wrote: printf("\n\nWant to delete the array?");
dec=getche();
if (dec=='y')
{
for (i=0;i<99;i++)
ch[i]=0;
}
Can I suggest you read up how strings (specifically null terminated strings) and arrays work in C?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Razanust wrote: count=sizeof(ch[100]);
As a side note, your code (possibly) does not own the memory at location ch[100] . While that variable holds 100 chars, they are numbered 0-99.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
I am new for vc++, i am doing project on vc++2008 clr base windows form application. not able to use inpout.dll in my project please help. if possible give example. thanks
|
|
|
|
|
It will be hard without a header and lib files to import DLL to your application. There are other alternatives as well.
Anyway See <a href="http://msdn.microsoft.com/en-us/library/kh1zw7z7(VS.71).aspx">this</a>[<a href="http://msdn.microsoft.com/en-us/library/kh1zw7z7(VS.71).aspx" target="_blank" title="New Window">^</a>]
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|