Ask a Question related to UNIX Programming, Design and Development.
-
Dermot Paikkos #1
newbie: memory fault(core dump)
First I should admit that I am a real novice and the code I am
submitting is directly out of UNIX System programming (1ed). It's a
menu program (curses) that I want to alter but I can't get the example
executable to run without getting a memory fault(core dump).
The system is Tru64 UNIX, 5.1, Cc V6.3
When it is compiled I get the following message:
cc: Info: veg.c, line 58: In this statement, the return type for
intrinsic "strlen" is being changed from "size_t" to "int".
(intrinsicint)
move(0, (COLS - strlen(m->m_title))/2);
This is the only indication of an error I get. Can anyone spot a problem
with the code?
Much appreicated.
Dp.
/* Example use of domenu */
#include <curses.h>
#include "menu.h"
/* This is the menu items. Change these to the values you
want the user to choose from */
char *mtab[8] = {
"option 1",
"option 2",
"option 3",
"",
"option 4",
"",
"option 5",
"option 6",
};
/* These are the definitions for the menu,
the size, title and a pointer to the menu items */
struct menu m1 = {
8, 8,
"Select an Option",
&mtab[0]
};
/* The domenu routine -- handles a simple menu */
domenu(m)
struct menu *m;
{
int option, lastoption,j,c,y,x;
char *p;
/* Save current terminal state then set modes */
savetty();
cbreak(), nonl(); noecho(); standend();
/* Empty screen */
clear();
/* initalise keypad, TRUE is defined in curses.h */
keypad(stdscr, TRUE);
/* print center title on line one */
move(0, (COLS - strlen(m->m_title))/2);
addstr(m->m_title);
/* Work out position for top left corner of menu */
y = (LINES - m->m_height)/2 + 1;
x = (COLS - m->m_width)/2;
/* display menu */
for(j = 0;j < m->m_height; j++)
mvaddstr(y+j, x, m->m_data[j]);
/* Initial values for cursoe pos. and option setting */
move( y, x);
/* This assumes first line in menu isn't blank */
lastoption = option = 0;
for(;;) {
/* remove hightlight bar from last option */
if(lastoption != option)
mvaddstr( lastoption+y, x,m->m_data[lastoption]);
/* put hightlight bar on current option */
standout();
mvaddstr( option+y, x, m->m_data[option]);
standend();
move(option+y,x);
/* Save current option */
lastoption = option;
refresh();
/* process input */
switch( (c = getch()) ) {
case '\r': /* option selected */
case '\n':
if(option < 0) {
beep();
break;
}
/* restore initial state and return */
resetty();
return option;
case KEY_DOWN: /* move current down */
case KEY_RIGHT: /* move current right */
do{
option = (++option < m->m_height) ? option: 0;
}while( isblank(m->m_data[option]) );
break;
case KEY_UP: /* move current line up or wrap */
case KEY_LEFT: /* round */
do{
option = (--option >= 0) ? option : m->m_height -1;
}while( isblank(m->m_data[option]));
break;
default: /* Try to match character */
for(j = 0; j < m->m_height; j++){
for(p = m->m_data[j]; *p == ' '; p++)
;
if( *p == '\0') /* blank line */
continue;
if( *p == c){
option = j;
break;
}
if( j >= m->m_height) /* no match */
beep();
break;
}
}
}
}
isblank(s) /* is string all spaces */
char *s;
{
while( *s == ' ')
s++;
return *s == '\0' ? 1:0;
}
main()
{
/* initscr(); */
domenu(&m1);
endwin();
}
======= menu.h file ========
/* menu.h -- contains defintiions of menu struncture */
struct menu {
int m_height; /* menu height */
int m_width; /* menu width */
char *m_title; /* Menu title */
char **m_data; /* pointer to data */
};
Dermot Paikkos Guest
-
ntpd core dump
Hi all, I have 5.3-RELEASE installed. I'm trying to run ntpd but I get a message in /var/log/messages that it exited on signal 11 (core dumped).... -
Memory fault - core dumped on SCO OpenServer
Everyone, I have a SCO OpenServer(TM) Release 3.2v5.0.5 machine that keeps giving me errors related to the printing process. I have included... -
ERROR: "memory fault - core dumped"
Hello, I have an SCO Unix 5.0.5, Pentium II with 128MB of memory and a 20GB hard disk with enough room on it. There's a system developed in Basic... -
gcc program core dump
There is a message of core dump may be related to the scope of variables , please any explainations . it's from a book of C .It is written as it is... -
How to dump core
In article <B5cna.60949$jVh.46894@news01.bloor.is.net.cable.rogers.com>, "Samuel T" <none@none.com> writes: May be a bit late now, but try... -
Valentin Nechayev #2
Re: newbie: memory fault(core dump)
>>> Dermot Paikkos wrote:
DP> When it is compiled I get the following message:
DP> cc: Info: veg.c, line 58: In this statement, the return type for
DP> intrinsic "strlen" is being changed from "size_t" to "int".
DP> (intrinsicint)
DP> move(0, (COLS - strlen(m->m_title))/2);
You forgot to #include <string.h>,
and to #include <ctype.h>
-netch-
Valentin Nechayev Guest
-
Jerry Feldman #3
Re: newbie: memory fault(core dump)
On Wed, 30 Jul 2003 12:17:42 +0000
Dermot Paikkos <dermot22@sciencephoto.co.uk> wrote:
That is just an info message from the compiler. DECC is generating> First I should admit that I am a real novice and the code I am
> submitting is directly out of UNIX System programming (1ed). It's a
> menu program (curses) that I want to alter but I can't get the example
> executable to run without getting a memory fault(core dump).
>
> The system is Tru64 UNIX, 5.1, Cc V6.3
>
> When it is compiled I get the following message:
> cc: Info: veg.c, line 58: In this statement, the return type for
> intrinsic "strlen" is being changed from "size_t" to "int".
> (intrinsicint)
> move(0, (COLS - strlen(m->m_title))/2);
functions, like strlen(3) as an instrinsic rather than executing
strlen(3) from libc. It's just telling you that it is casting strlen to
return a 32 bit int rather than a 64 bit long.
--
Jerry Feldman <gaf-nospam-at-blu.org>
Boston Linux and Unix user group
[url]http://www.blu.org[/url] PGP key id:C5061EA9
PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
Jerry Feldman Guest



Reply With Quote

