Undefine array in C   Independent houses near kukatpally | Apartments in Pragathi Nagar | AndhraVaani.com | Log Out | Topics | Search
Register | Edit Profile

Bewarse Talk � Technology - Talk Only Tech � Undefine array in C � Previous Next �

Author Message
Top of pagePrevious messageNext messageBottom of pageLink to this message

Smart
Mudiripoyina Bewarse
Username: Smart

Post Number: 3531
Registered: 03-2004
Posted From: 207.199.2.34

Rating:N/A
Votes: 0(Vote!)

Posted on Friday, May 06, 2005 - 12:00 pm:Edit PostDelete PostView Post/Check IP

>>when I undefine an array like this can I populate the array again?

you are not undefining anything here.

When u define an integer or an array, most compilers initialize it with a value 0. So, we are making the contents of the array 0 by this method.

array is still valid, and u can use it.

To understand whats happening with this code, just print out the values of the array before and after this code.
Top of pagePrevious messageNext messageBottom of pageLink to this message

Aavakaaya
Pilla Bewarse
Username: Aavakaaya

Post Number: 481
Registered: 04-2004
Posted From: 195.220.151.50

Rating:N/A
Votes: 0(Vote!)

Posted on Friday, May 06, 2005 - 11:54 am:Edit PostDelete PostView Post/Check IP

thank you I will try this..

meanwhile.. when I undefine an array like this can I populate the array again?
Top of pagePrevious messageNext messageBottom of pageLink to this message

Smart
Mudiripoyina Bewarse
Username: Smart

Post Number: 3530
Registered: 03-2004
Posted From: 207.199.2.34

Rating:N/A
Votes: 0(Vote!)

Posted on Friday, May 06, 2005 - 11:47 am:Edit PostDelete PostView Post/Check IP

You can use either:

memset(yourarray, 0, sizeof yourarray);

or

for( int i = 0 ; i < sizeof( yourarray ) / sizeof( yourarray[ 0 ] ) ;
++ i ) {
yourarray[ i ] = 0 ; // or some other "clear" value
}



If it is a char array, just set the first element to '\0'
Top of pagePrevious messageNext messageBottom of pageLink to this message

Aavakaaya
Pilla Bewarse
Username: Aavakaaya

Post Number: 480
Registered: 04-2004
Posted From: 195.220.151.50

Rating:N/A
Votes: 0(Vote!)

Posted on Friday, May 06, 2005 - 11:39 am:Edit PostDelete PostView Post/Check IP

>>what type of array are u using?
int
Top of pagePrevious messageNext messageBottom of pageLink to this message

Smart
Mudiripoyina Bewarse
Username: Smart

Post Number: 3529
Registered: 03-2004
Posted From: 207.199.2.34

Rating:N/A
Votes: 0(Vote!)

Posted on Friday, May 06, 2005 - 11:38 am:Edit PostDelete PostView Post/Check IP

what type of array are u using?
char or int or ??
Top of pagePrevious messageNext messageBottom of pageLink to this message

Aavakaaya
Pilla Bewarse
Username: Aavakaaya

Post Number: 479
Registered: 04-2004
Posted From: 195.220.151.50

Rating:N/A
Votes: 0(Vote!)

Posted on Friday, May 06, 2005 - 11:35 am:Edit PostDelete PostView Post/Check IP

I created the array dynamically through pointer decleration.

I tried

void free(void *ptr);

but no use.

any other suggestions.

There is no undefine in C I guess.
Top of pagePrevious messageNext messageBottom of pageLink to this message

Michael_corleone
Pilla Bewarse
Username: Michael_corleone

Post Number: 32
Registered: 05-2005
Posted From: 203.200.95.130

Rating:N/A
Votes: 0(Vote!)

Posted on Friday, May 06, 2005 - 11:24 am:Edit PostDelete PostView Post/Check IP

Don COrleone septhe lang motham thirigi raayaalsine
Top of pagePrevious messageNext messageBottom of pageLink to this message

Kushi_ram
Celebrity Bewarse
Username: Kushi_ram

Post Number: 9215
Registered: 04-2004
Posted From: 192.63.80.98

Rating:N/A
Votes: 0(Vote!)

Posted on Friday, May 06, 2005 - 11:20 am:Edit PostDelete PostView Post/Check IP

kiki Manchi logic e kani C lo undefine operator unda.. KIKI
Top of pagePrevious messageNext messageBottom of pageLink to this message

Michael_corleone
Pilla Bewarse
Username: Michael_corleone

Post Number: 26
Registered: 05-2005
Posted From: 203.200.95.130

Rating:N/A
Votes: 0(Vote!)

Posted on Friday, May 06, 2005 - 11:14 am:Edit PostDelete PostView Post/Check IP

undefine array_name[no. of bytes to undefine ]
Top of pagePrevious messageNext messageBottom of pageLink to this message

Gaali 
Pilla Bewarse
Username: Gaali 

Post Number: 3
Registered: 05-2005
Posted From: 149.166.137.217

Rating:N/A
Votes: 0(Vote!)

Posted on Friday, May 06, 2005 - 11:04 am:Edit PostDelete PostView Post/Check IP

kill bill :-)
Top of pagePrevious messageNext messageBottom of pageLink to this message

Kushi_ram
Celebrity Bewarse
Username: Kushi_ram

Post Number: 9213
Registered: 04-2004
Posted From: 192.63.80.98

Rating:N/A
Votes: 0(Vote!)

Posted on Friday, May 06, 2005 - 11:02 am:Edit PostDelete PostView Post/Check IP

dynamic memory allocation vadu mama...
Top of pagePrevious messageNext messageBottom of pageLink to this message

Gaali 
Pilla Bewarse
Username: Gaali 

Post Number: 2
Registered: 05-2005
Posted From: 149.166.137.217

Rating:N/A
Votes: 0(Vote!)

Posted on Friday, May 06, 2005 - 11:01 am:Edit PostDelete PostView Post/Check IP

Good question

answer will follow now
Top of pagePrevious messageNext messageBottom of pageLink to this message

Aavakaaya
Pilla Bewarse
Username: Aavakaaya

Post Number: 478
Registered: 04-2004
Posted From: 195.220.151.50

Rating:N/A
Votes: 0(Vote!)

Posted on Friday, May 06, 2005 - 10:35 am:Edit PostDelete PostView Post/Check IP

am doing some very basic prog in C...
is there a way to undefine an array.

am reading from a file and populating an array...at the end of reading each line I'll check some condition..if it fails I want to clear the array.

How can I do this.