|
no the algo , i just wanted to find some ways to accomplish the task and find out the most efficient way to do.
|
|
|
|
|
I am using
fseek( stream, 0L, SEEK_END);
fseek( stream, -sizeof(FileAdd), SEEK_CUR);
to go to the last structure and will then go the second last and so on....
Please suggest some other alternatives.
Rohit
|
|
|
|
|
One useful suggestion is that you can store your data in file with sort or indexing these data. Do you know how looks like indexed relation database?
|
|
|
|
|
Hi,
I'm a newbie at MFC and was wondering how I could accomplish putting a green border with round edges around buttons using VC++. You help is appreciated.
|
|
|
|
|
|
I looked at those. I was wondering is there a way I can put borders around the default buttons without having to create owner drawn buttons?
Thanks
|
|
|
|
|
nikimonkey wrote:
I was wondering is there a way I can put borders around the default buttons without having to create owner drawn buttons?
Not that I know of right off, but we're making one[^]. These controls will be fully skinnable, too.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
The simplest method is to drawing rectagle.
|
|
|
|
|
Hello, everyone!
Suppose I define a global variable in a .h file, for example,
"int counter", I want to know when the space of this variable is
allocated. I am not sure whether it is allocated when the .h file is
first included in another file or when the global variable is first
used in a specific function. Maybe allocated during compiling?
Can anyone help? Another question, when the space of this variable is
freed? Maybe the space of this variable is always existing during the
life of the whole program.
Thanks in advance,
George
|
|
|
|
|
Keep the use of global variables to a minimum. Many would even say never use them, but I believe they have their uses.
Global variables are declared in only one *.c/*.cpp file, not *.h files. If you want to access the global variable from another *.c/*.cpp file use the extern keyword. Use extern in *.h files also.
Space is allocated when the program runs, and is freed when the program exits.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks, PJ buddy!
You have correct one of my years-old mistakes in C/C++ programming. I have a further question. The extern key word is used only with variables and not with functions. Am I correct?
You have also said "Space is allocated when the program runs". Do you mean even if you do not use this variable in the program, the space is also allocated? And it is run-time allocation and not compile-time allocation. Am I also correct?
regards,
George
|
|
|
|
|
well well the word extern can be used with the function also.
mostly when a function is a global function its prototype have extern in it.
Yes the memory is allocated even if the Variable is not used in the program .
The allocation for such Variable is done Run-time
i hope this has solved ur query
Thanx
TAKE CARE
|
|
|
|
|
Hi, siid buddy!
Thank you for making me understand when the memory is allocated.
It seems most people do not support your opinion about "extern" keyword. What is your opinion?
regards,
George
|
|
|
|
|
No the extern keyword can be used with functions just declare as follows :
extern bool GetLength(char* str);
then you can call it like any other function.
|
|
|
|
|
Only as long as it is defined in another .cpp or.h file that the linker can link against
|
|
|
|
|
Thanks, Dangleberry buddy!
Do you mean "extern" keyword is not useful with functions? I am not quite sure about your meaning.
regards,
George
|
|
|
|
|
Hi,
ny default all functions delareed in header files are extern (giving global access), that is the use of the extern keyword is not needed.
All variables declared in headerfiles are assumed to be internal (are local), that's the why you need to declare global variables as extern.
To make a function local (or internal) you must not use the keyword intern but static!
G. Steudtel
|
|
|
|
|
Thanks, G. Steudtel buddy!
I think variables defined in one header file without "extern" keyword
can be used in another file when you use "#include" keyword.
So, I think what you said "All variables declared in headerfiles are assumed to be internal (are local), that's the why you need to declare global variables as extern." is not correct.
regards,
George
|
|
|
|
|
George2 wrote:
I think variables defined in one header file without "extern" keyword
can be used in another file when you use "#include" keyword.
Are you sure? Please try this:
#include "mod.h"
void main()
{
iGlobalNumber = 2;
}
--------------------------------------
#include "mod.H"
void Test()
{
iGlobalNumber = 1;
}
--------------------------------------
#ifndef _MY_HEADER_FILE_H_
#define _MY_HEADER_FILE_H_
int iGlobalNumber;
#endif // _MY_HEADER_FILE_H_
---------------------------------------
You will get this:
mod.obj : error LNK2005: "int iGlobalNumber" (?iGlobalNumber@@3HA) already defined in main.obj
BuggyMax
|
|
|
|
|
Thanks, BuggyMax buddy!
I have tried youtr exmaple and find you are correct.
But I do not know why the error message is
--------
int iGlobalNumber" (?iGlobalNumber@@3HA) already defined
--------
Why is it "already defined"?
regards,
George
|
|
|
|
|
Well, from the view of the C++ linker, my previous example code would be something like this:
[the whole pseudo code in one single source file]
int iGlobalNumber;
void main()
{
iGlobalNumber = 2;
}
int iGlobalNumber;
void Test()
{
iGlobalNumber = 1;
}
Regarding to the above issue, you may have a look at chapter 9 or 10 (I forgot) in the book "The C++ Programming Language" 3rd edition by Bjarne Stroustrup.
George2 wrote:
(?iGlobalNumber@@3HA)
C++ uses mangled names to serve polymorphism, overloading, etc.
You can take a look at this link: C++ Name Mangling/Demangling[^]
BuggyMax
|
|
|
|
|
Thanks, BuggyMax buddy!
I have added "extern" keyword before int in main.cpp and mod.cpp, but the error still remains the same. How to resolve the trouble?
regards,
George
|
|
|
|
|
The solution is, you can only declare global variables in *.CPP.
[file mod.h]
#ifndef _MY_HEADER_FILE_H_
#define _MY_HEADER_FILE_H_
void Test();
#endif // _MY_HEADER_FILE_H_
--------------------------------
[file main.cpp]
#include "mod.h"
int iGlobalNumber;
void main()
{
iGlobalNumber = 2;
Test();
}
-----------------------------------
[file mod.cpp]
extern int iGlobalNumber;
void Test()
{
iGlobalNumber = 1;
}
------------------------------------
BuggyMax
|
|
|
|
|
Thanks, BuggyMax buddy!
You have corrected another one of my years-old mistakes.
regards,
George
|
|
|
|
|
i am really real newbie when it comes to c++. i just got the "Teach Yourself C++ in 21 Days" book and it is great. there is a sample code in there that i think everyone knows called the "hello world" code. which is:
#include <iostream><br />
<br />
int main()<br />
{<br />
std::cout << "Hello World!\n";<br />
return0;<br />
}
but in viusal C++ 6.0, i tried to build it, but it gives the error:
Compiling...<br />
hello.cpp<br />
c:\documents and settings\owner\desktop\hello.cpp(6) : error C2065: 'return0' : undeclared identifier<br />
c:\documents and settings\owner\desktop\hello.cpp(7) : warning C4508: 'main' : function should return a value; 'void' return type assumed<br />
Error executing cl.exe.<br />
<br />
hello.exe - 1 error(s), 1 warning(s)<br />
i have tried a few other sample codes and they all give me similar errors.
btw, i just installed visual c++ 6.0 standard, and i have made no changes to the settings.
any help would be appreciated. thanks in advance
|
|
|
|