- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: C Question: char messagebuf[8199999]
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-05-2013 03:00 PM
тАО06-05-2013 03:00 PM
Hello Folks;
I know this isn't exactly an admin question - but I know someone can easily answer it.
I wrote a simple "grim reaper" program to go through the /var/log/message file
and remove all the useless (as far as I'm concerned) messages that Fedora 16
generates.
Here's a short chunk of code:
"NOTE: the [char messagebuf] is shown with 2 values: one works, one doesn't . They aren't both in the code at the same time] :-)
--------
char messagebuf[8199999]; [NOTE THIS WORKS]
char messagebuf[10199999]; [NOTE THIS CAUSES segmentation faults]
FILE *messagefp;
if((messagefp = fopen(MESSAGE, "r")) == NULL)
{
printf ("ERROR: could not open file: %s \n", MESSAGE);
return 0;
}
while(fscanf(messagefp, "%c", &messagebuf[dataend]) == 1)
++dataend;
fclose(messagefp);
--------
The problem is when I increase the value of messagebuf past 8MB, I get a segmentation fault (core dumped) When I execute it regardless of the size of the input file.
Question: how can I make char messagebuf[>8MB]?
regards,
tonyp
Solved! Go to Solution.
- Tags:
- ARRAY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-05-2013 04:03 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-05-2013 05:17 PM
тАО06-05-2013 05:17 PM
Re: C Question: char messagebuf[8199999]
Hello Steven;
Thanx for your help, Steven.
I set the "static char messagebuf[10000000] and it compiled and ran fine.
regards,
tonyp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2013 01:49 AM
тАО06-08-2013 01:49 AM
Re: C Question: char messagebuf[8199999]
>I increase the value of messagebuf past 8MB, I get a segmentation fault when I execute it regardless of the size of the input file.
Based on Steven's comments about stack size, if the stack grows towards 0, then the first byte you put into the array will be beyond the top of the stack.