Hi ALL,
I have a doubt regarding declaration of static variable.
Suppose if we declare a char array as static then when the memory
reserved for the elements of the array will be de allocated .For
example when the memory reserved for "array[10]" will be de
allocated ?
#include<stdio.h>
char *return_static();
int main(void)
{
char *received = NULL;
received = return_static();
printf("\n Contain of array = %s\n",received);
return 0;
}
char *return_static()
{
static char array[10]={"hello"};
return array;
}
Regards,
Somenath 7 1756
lan collins is right,static member will be deallocated when app
exit,refer below example:
#include <stdio.h>
class CTest
{
public: CTest(){ printf("allocate!\n");}
~CTest(){ printf("deallocate!\n");}
void dosomething(){ printf("do something!\n"); }
};
CTest& return_static();
int main(int argc, char* argv[])
{
CTest& t= return_static();
t.dosomething();
return 0;
}
CTest& return_static()
{
static CTest t;
return t;
}
somenath wrote:
Hi ALL,
I have a doubt regarding declaration of static variable.
Suppose if we declare a char array as static then when the memory
reserved for the elements of the array will be de allocated .For
example when the memory reserved for "array[10]" will be de
allocated ?
You asked this question a while ago and got answers. If you're posting
through Google Groups, it's recommended to wait for a few hours, for your
post, and any replies to it, to show up, before attempting reposting. The
latency of the Google Groups interface is much more than traditional Usenet
access.
Little guy wrote, On 31/07/07 09:03:
lan collins is right,static member will be deallocated when app
exit,refer below example:
#include <stdio.h>
class CTest
{
public: CTest(){ printf("allocate!\n");}
<snip>
Why are you posting C++ to a C group? It is not topical and not relevant
to what goes on with C.
--
Flash Gordon
Little guy wrote:
lan collins is right,static member will be deallocated when app
exit,refer below example:
#include <stdio.h>
class CTest
{
public: CTest(){ printf("allocate!\n");}
~CTest(){ printf("deallocate!\n");}
void dosomething(){ printf("do something!\n"); }
};
You are confused as to which newsgroup you are reading. This is not a
C++ group.
Brian
santosh <sa*********@gmail.comwrote:
You asked this question a while ago and got answers. If you're posting
through Google Groups, it's recommended to wait for a few hours, for your
post, and any replies to it, to show up, before attempting reposting. The
latency of the Google Groups interface is much more than traditional Usenet
access.
It can possibly be up to a few days, based on some accounts I seem to
recall. Unfortunately it often chances that posts show up
immediately, leading to the misconception that something is broken
when they do not.
--
C. Benson Manica | I appreciate all corrections, polite or otherwise.
cbmanica(at)gmail.com |
----------------------| I do not currently read any posts posted through
sdf.lonestar.org | Google groups, due to rampant unchecked spam.
On Thu, 2 Aug 2007 15:58:48 +0000 (UTC), Christopher Benson-Manica
<at***@faeroes.freeshell.orgwrote:
>santosh <sa*********@gmail.comwrote:
>You asked this question a while ago and got answers. If you're posting through Google Groups, it's recommended to wait for a few hours, for your post, and any replies to it, to show up, before attempting reposting. The latency of the Google Groups interface is much more than traditional Usenet access.
It can possibly be up to a few days, based on some accounts I seem to recall. Unfortunately it often chances that posts show up immediately, leading to the misconception that something is broken when they do not.
Why is that a misconception? When Google fails to deliver posts for
days, "broken" seems a fair description.
--
Al Balmer
Sun City, AZ
Al Balmer <al******@att.netwrote:
On Thu, 2 Aug 2007 15:58:48 +0000 (UTC), Christopher Benson-Manica
<at***@faeroes.freeshell.orgwrote: (without appropriate care)
It can possibly be up to a few days, based on some accounts I seem to
recall. Unfortunately it often chances that posts show up
immediately, leading to the misconception that something is broken
when they do not.
Why is that a misconception? When Google fails to deliver posts for
days, "broken" seems a fair description.
"...leading to the misconception that the post will never show up,
when in fact it will." That's what I should have said. Thanks.
I suppose the real misconception is that using Google groups
effectively is easy and reliable.
--
C. Benson Manica | I appreciate all corrections, polite or otherwise.
cbmanica(at)gmail.com |
----------------------| I do not currently read any posts posted through
sdf.lonestar.org | Google groups, due to rampant unchecked spam. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: pvinodhkumar |
last post by:
The number of elemets of the array, the array bound must be constant
expression?Why is this restriction?
Vinodh
|
by: Simon Schaap |
last post by:
Hello,
I have encountered a strange problem and I hope you can help me to
understand it. What I want to do is to pass an array of chars to a
function that will split it up (on every location where...
|
by: Gattaca |
last post by:
I would like to create a matrix of integers by allocating memory
dynamically (malloc or calloc) because i and j are defined during
execution of the program.
I have got not problem to do this in...
|
by: kaul |
last post by:
i want to create a 2-d array containg r rows and c columns by dynamic
memory allocation in a single statement so that i will be able to access
the ith and jth index as say arr
how is that...
|
by: D |
last post by:
hi,
i would like to know how to calculate the size of a dynamic array
created using a dereference declaration like int *numbers and
allocating via malloc or calloc: numbers=(int...
|
by: Sam |
last post by:
Hello I have a structure called Company.
struct Company
{
char *employee;
char *employee_address;
};
I want to build an array of this structure but the number of employees
will change...
|
by: heddy |
last post by:
I have an array of objects. When I use Array.Resize<T>(ref Object,int
Newsize); and the newsize is smaller then what the array was
previously, are the resources allocated to the objects that are...
|
by: Peterwkc |
last post by:
Hello all expert, i have two program which make me desperate bu after i have noticed the forum, my future is become brightness back.
By the way, my problem is like this i the first program was...
|
by: somenath |
last post by:
Hi ALL,
I have a doubt regarding declaration of static variable.
Suppose if we declare a char array as static then when the memory
reserved for the elements of the array will be de allocated...
|
by: aeo3 |
last post by:
Hi All,
Now, I am trying to build a project, I need to expand an array of pointer to classes. Moreover, this array includes some elements I want to delete them. So, I create another array, copy the...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |