| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Realloc() |
> I was wondering if someone might be able to give me an example of how
> to use realloc,
#include
#include
int main(void)
{
char *buffer, *new_buffer;
buffer = malloc(80);
if(!buffer) {
/* unable to allocate initial buffer */
return EXIT_FAILURE;
}
new_buffer = realloc(buffer, 100);
if(!new_buffer) {
/* unable to allocate larger buffer */
return EXIT_FAILURE;
}
buffer = new_buffer;
/*
* do something with buffer
*
* ...
*
*/
free(buffer);
return EXIT_SUCCESS;
}
--- Msgedsq/2 3.30
* Origin: Blizzard of Ozz, Melbourne, Australia (3:633/267.1{at}fidonet)SEEN-BY: 50/99 620/243 623/630 632/348 360 998 633/154 260 267 371 373 374 SEEN-BY: 634/384 635/301 502 503 544 639/252 711/401 409 410 413 430 510 808 SEEN-BY: 711/809 932 934 712/515 713/888 714/906 800/1 7877/2809 @PATH: 633/267 374 371 635/503 50/99 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.