- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - Linux
- >
- System Administration
- >
- Re: C Question: char messagebuf[8199999]
-
- Forums
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Blogs
-
Information
-
English
- 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
- Email to a Friend
- 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
- Email to a Friend
- Report Inappropriate Content
06-05-2013 04:03 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- 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
- Email to a Friend
- 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.
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2021 Hewlett Packard Enterprise Development LP