|
Doing this with C language programming is not difficult; just a few statements.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Have you considered fscanf() ?
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
fp=fopen("SDetails.txt","r+");
while(1)
{
ch=fgetc(fp);
if(ch==EOF)
break;
fscanf(fp, "%d", &myInt);
printf(" %d ",myInt);
sum=sum+myInt;
}
printf("%d",sum);
fclose(fp);
what i did was like above ..but it print the same int 3 times ..i cant find the error...please help
now i can read only ints from the file..thx
|
|
|
|
|
What you have will never work as you expect. The call to fgetc() is going to advance the file pointer, then fscanf() is going to be reading from the middle of some byte. Have you checked the return value from fscanf() ? If it does not find a number to read from the file, it may be retaining the last read value.
Is your file laid out something like:
Name1,288,7099,441
Name2,1500
Name3,587,208
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
and not when i create the window .
thanks
i found what i need is call WS_DISABLED
but how i set this parameter on a button.again not when i create this window but after
nevermind i just create the window again when i get in the function with disable and when i finish i create again the window without disable
modified 14-Jan-12 18:31pm.
|
|
|
|
|
To disable a button (or any window or control) after it has been created, use the EnableWindow(hButton, FALSE); API call.
To get the handle to the button, use the GetDlgItem API.
|
|
|
|
|
I can't seem to get the function pointers working?
anybody see what's wrong? I just want to call the print()method
#include "stdio.h"
class TMyClass
{
public:
void print(){ printf("Print!\n"); };
void (TMyClass::*pt2Member)();
TMyClass(void);
};
TMyClass::TMyClass(void)
{
pt2Member = &TMyClass::print;
};
int main(int argc, char* argv[])
{
TMyClass instance1;
instance1.pt2Member;
return 0;
}
|
|
|
|
|
To call a member function using pointers you have to use the pointer to member operators (.* or ->* or ::* ).
But declaring the function pointer inside the class is not very helpful.
Usually the function pointer is declared outside the class like this -
void (TMyClass::*pt2Member)() = &TMyClass::print;
The above declaration may be done globally or inside the main function.
In this case, the function call would be as follows -
TMyClass instance1;
(instance1.*pt2Member)();
If, however, you do wish to declare the pointer inside the class like you've done here, the calling syntax would be a little weird and would look like this -
TMyClass instance1;
(instance1.*instance1.pt2Member)();
|
|
|
|
|
you earned your title 'superman'
thank you!!! works like a charm
|
|
|
|
|
Hello,
What i have is a video stream coming in, for every incoming frame i have to calculate the frame histogram and to display it graphically in the GUI.
So i have to redraw the histogram on the GUI every frame.
My problem is that i don't know how to draw the histogram,what controls to use,what functions or classes can help me?
Thanks.
|
|
|
|
|
|
Hi Developers,
I am using a MDI based application. I am trying to open a view and it's showing the background image on it. It's like overlaps it's own screen and background screen. I have not used any drawing function at all.
Can any one help me.
Thanks in Advance.
Amrit Agrawal
Software Developer, Mumbai
|
|
|
|
|
Amrit Agr wrote: it's showing the background image on it. It's like overlaps it's own screen and background screen.
I am having difficulty visualising exactly what you are seeing. Rather than 'it' can you explain which part of each window is showing what values. What do you see in the Main window, what do you see in the View, and where is the background from?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
i want to print two parameter from my struct but it doesnt print to me
GetWindowText(hwndEdit[0],arr.last,10);
GetWindowText(hwndEdit[1],arr.first,10);
MessageBox(hwnd,TEXT((LPCWSTR)arr.last(LPCWSTR)arr.first),TEXT("bla"),MB_OK);
how can i fix\what is the syntax ?
|
|
|
|
|
You can only pass a single string to the MessageBox() function. Use sprintf() or the appropriate variant to create a single character array containing your complete message.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hi,
The problem is with your conversion..
Cheers
|
|
|
|
|
You need to concatenate the strings first before you call MessageBox .
As Richard said, you can use sprintf to do this.
If you have wide character strings, you must use the swprintf function instead.
You could also use the _stprintf (or _stprintf_s ) macro which would cater for both sprintf (sprintf_s ) or swprintf (swprintf_s ) depending on whether UNICODE is defined.
You can also use the _tcscat (or _tcscat_s ) macro to do this.
Other options are to use the CString += operator or the std::wstring += operator .
|
|
|
|
|
Hi all,
I have made a dialog based application, and in that application i have a tree as well as list control.
What i want is, when i click on a item in tree control my corresponding item in List control should get its font bold or should change its text colour.
I was trying to do it using customcontrol method but its not working.
how can i do this???
|
|
|
|
|
VCProgrammer wrote: I was trying to do it using customcontrol method but its not working.
Since we cannot see your code it's impossible to suggest what you may be doing wrong. Try editing your question and adding the code (within <pre> tags) that you are having trouble with.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
|
I've created win32 API project for work with mysql. Each window form has *.cpp file. In window "main.cpp" I created connection to MySQL database via variable MYSQL * mysql5. Another window named "income" (income.cpp) must use variable "mysql5" to create a question.
How can I obtain the value "mysql5" in file income.cpp?
main.cpp:
#include "main.h"
mysql_real_connect(mysql5, HOST, USER, PASSWORD , DATABASE , PORT, UNIX, 0 );
main.h:
static MYSQL *mysql5;
income.cpp:
mysql_query( mysql5, "question" ); //now suddenly mysql5 is null
modified 13-Jan-12 17:24pm.
|
|
|
|
|
Global is probably not the best option in C++, but I'll answer your question nonetheless...
In main.h, where did you declare mysql5? Is it in the global namespace or is it in a class? If it's in the global namespace, you probably have to remove the static declaration since that'll limit the visibility of the variable.
Assuming it is in the global namespace, in income.cpp, did you remember to declare mysql5?
extern MYSQL *mysql5;
Lastly... in C++, it's probably a better idea to use a member variable and pass the parameter that way when the object is constructed or through a Set() method.
|
|
|
|
|
Thank you for the answear.
If I remove the static declaration I receive errors like this : error LNK2005: "struct st_mysql * mysql5" (?mysql5@@3PAUst_mysql@@A) already defined in main.obj.
Adding
extern MYSQL *mysql5; do nothing.
Here are details:
main.h:
#include "ClassLogin.h"
static MYSQL *mysql5;
static ClassLogin *login2;
DlgLogin.cpp - contains dialog procedure and #include "main.h"
case button_OK:
ClassLogin * login = new ClassLogin(...parameters...);
login2 = login;
ClassLogin.cpp:
#include "main.h"
#include "ClassLogin.h"
ClassLogin::ClassLogin();
ClassLogin::ClassLogin(...parameters...)
{ ... mysql_real_connect(Cmysql, host, user, password , database , port, unix, 0 );
mysql5 = Cmysql; }
destructor
Class ClassLogin
{
public:
ClassLogin();
ClassLogin(...parameters...);
MYSQL *Cmysql;
virtual ~ClassLogin();
};
income.cpp - contains dialog procedure and
#include "main.h"
#include "ClassLogin.h"
MYSQL * mysql2;
case button_OK:
mysql2 = login2->Cmysql;
mysql2 = mysql5;
But if I don't use login2->Cmysql or mysql2 = mysql5 the values are right (0x01df0a98) while debuging (F5)
What I have to do to obtain values from class ClassLogin in another cpp file?
Jan
|
|
|
|
|
You may:
in main.h remove the line
static MYSQL *mysql5;
in DlgLogin.cpp add the line
MYSQL * mysql5;
in income.cpp add the line
extern MYSQL * mysql5;
Now the variable in income.cpp is exactly the same of DlgLogin.cpp so no assignemnt is required.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thank you. This function.
|
|
|
|