|
I figured it out. Took few minutes to type this[^]. lol that's great you got it!
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
I guess in any C program argv[0] is the program name...
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]
|
|
|
|
|
Endomlic wrote: I guess in gcc argv 0 is the program name.
Not just in gcc, it's the same everywhere. good night!
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
I missed this one.
Thanks to an anonymous report (or 'signalation?' ) it is now in the list it deserves...[^]
Welcome again in the CP's memorable quotes page, Rajesh.
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]
|
|
|
|
|
This should never compile. You must declare arrays with literals or assign them so the complier can calculate a size. When you create this array the size of the array * the sizeof(char) will be subtracted from the stack pointer. If you want a dynamic array you have to use malloc.
When you use a char * and a malloc the Size of buff is the size of a char * which will be 4 regardless of how much memory you allocate. In C you will need to maintain a separate value to indicate the size of the allocated array that is why every api function that takes an allocated buffer also takes a parameter that specifies the size of the buffer or a buffer that has a way of indicating the end element as is in a null terminator on the end of char strings.
a programmer traped in a thugs body
|
|
|
|
|
HI ..i want to convert a key board input to uppercase while typeing from keyboard.
how should i handle it..
Please provide comment
|
|
|
|
|
convert your input using toupper()
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
pandit84 wrote: i want to convert a key board input...
Are you using getch() ?
"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've been using static members inside class for years and I've been doing the traditional static-initialization outside the class too. But only when I'm in a poetic++ mode, I'd re-think about the practices.- Why should I really do it?? The compiler that's bending the world, can't be written to address this trivial requirement? Or it'd break any "conviction" made by Stroustroup? Why not it let people initialize a static member inside the constructor? Though it need not impact the memory allocation scheme, it would give the programmers a better feel..
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
When you refer to 'the constructor', do you mean a static constructor, like in C#? C++ doesn't have static constructors. I don't know if C+0x is going to support that or not (it might be nice if it did).
With an instance constructor, you can set static members just like instance members. Each instance of a class can modify a static member.
I'm not sure what you're saying is missing .
|
|
|
|
|
Gary R. Wheeler wrote: like in C#? C++ doesn't have static constructors. I don't know if C+0x is going to support that or not (it might be nice if it did).
Yeah something similar.
Gary R. Wheeler wrote: With an instance constructor, you can set static members just like instance members. Each instance of a class can modify a static member.
Yup, but for example:
class CodeProject
{
static int x;
int y;
CodeProject()
{
x=0;
y=0;
}
};
The above won't work without we initializing it again in the .cpp.(int CodeProject::x=0 ). In specific it must be in .cpp - it won't work if we initialize the static member in the header. Just thought about these limitations & felt it might be possible to disguise a static member as an instance member and treat it the same way. (though internal implementation would differ).
And yup, I wish C+0x have this feature unless they've been following this way for any specific reasons.
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
Stricly speaking, you don't have to initialize the value when you define it:
int CodeProject::x; in the CPP source file. The language designers left it up to the programmer where to place the definition, rather than arbitrarily placing it somewhere themselves. Interestingly enough, the C++ language places relatively few requirements on where in your source code you do things.
|
|
|
|
|
Gary R. Wheeler wrote: Stricly speaking, you don't have to initialize the value when you define it:
Yeah the proper word to address that would be to "Define"-it-again.. but to exercise discipline I initialized it & hence called it "initialize".
Gary R. Wheeler wrote: n the CPP source file. The language designers left it up to the programmer where to place the definition, rather than arbitrarily placing it somewhere themselves. Interestingly enough, the C++ language places relatively few requirements on where in your source code you do things.
Yeah but why not they allow us to define it in the constructor? As we have declared the member as "static" the compiler would be aware - it's a static one and allocate memory accordinly. That's possible right? But why does it get fussed up and asks the user to do all these? .. that was my thought. Or I'm missing something?
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
VuNic wrote: why not they allow us to define it in the constructor?
There isn't a way for the compiler to tell the difference between initialization, which you only want to do once for a static member, and a normal assignment, which you may want to do every time you construct a new instance.
|
|
|
|
|
Gary R. Wheeler wrote: here isn't a way for the compiler to tell the difference between initialization, which you only want to do once for a static member, and a normal assignment, which you may want to do every time you construct a new instance.
Yeah.. the compiler could've been equipped with that awareness.
Gary R. Wheeler wrote: delete this;
Within the context quite!. lol
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
VuNic wrote: The above won't work without we initializing it again in the .cpp.
You aren't (just) initializing it - you are defining (i.e. reserving storage for) it.
If you could define (as in reserve storage for) the static item in the class definition, then where would the static item's storage live? Each .cpp file that included the header with the class definition would contain storage for the item. You would need some intelligence in the linker to merge all allocations of the static item. Now, that intelligence might exist today, but it sure didn't back when Bjarne designed C++.
I suspect the Annotated C++ Reference[^] might well provide insight into these design decisions. I have got and have read that book, but not for a while.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Explanation here[^] Yep,I meant definition.
Stuart Dootson wrote: You would need some intelligence in the linker to merge all allocations of the static item. Now, that intelligence might exist today, but it sure didn't back when Bjarne designed C++.
Exactly, what I tried to think! Also thanks for the link.. could be the 4rd book on C++.
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
Can you give a real example of where you would use this ?
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
C# - static constructors.
The idea is not going to be revolutionary. But as I said, it'd be better for the coder. A neat idea.
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
I realize C# has static con, but i was looking for a real world use in C++.
The only example i can think of is where the static is a pointer to a dynamically allocated object. The static cons would alloc, the static des would free.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
cmk wrote: but i was looking for a real world use in C++.
Any example where you use a static variable would do. My thought is simple. A class can continue to represent it's core, solid members, in addition to that, it could house static variables and mimic the usage of static variables as if they are members of the class, instead of the messy-current implementation. C# static constructor looks like one way of managing the static clutters inside the class. The idea sounded good at least. Stuarts had better expressed the same below. You might look at that one too.
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
In addition to the above comments, also notice that you might access a static variable of a class before you have any instances of it.
|
|
|
|
|
Niklas Lindquist wrote: In addition to the above comments, also notice that you might access a static variable of a class before you have any instances of it.
leaves me thinking. Yep so C# is right by having a static constructor. I think it takes care of this scenario. Let me dive into it & test . Thanks man
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
Hi to all,
Please suggest me a good 'AVC/H.264 Video Decoder", having 'Quarter Resolution' property.
Thanks & Regards,
Aniket A. Salunkhe
|
|
|
|
|