Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #7014

Re: a little c programming that no works!!

From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c
Subject Re: a little c programming that no works!!
Date 2011-06-27 16:07 +1200
Message-ID <96qdvuF2dgU2@mid.individual.net> (permalink)
References <e4f31412-ae7a-455f-9296-3cca0bbccedb@g16g2000yqg.googlegroups.com>

Show all headers | View raw


On 06/27/11 03:50 PM, Vinicio Flores wrote:
> Hello C hackers, this program that I am writing print "Segmentation
> fault" when I execute it, I think that the problem is the gets
> function,  but I am not sure

Don't use gets(), use fgets().

<snip>

> static int open_and_fill_database(char *arg)
> {
>    FILE *database;
>
>    struct datbase_registers *base = malloc ( sizeof(struct registers
> *));

You should check to see if this succeeds!

<snip>

> #define MAX    ((900*800)*256)

Are you serious? 184 million!


> struct datbase_registers
> {
>    char regname[MAX];
>    char name[MAX];
>    long int ntel;
>    long int age;
> };

So one of these is > 400MB!

-- 
Ian Collins

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

a little c programming that no works!! Vinicio Flores <vfloreshdz@gmail.com> - 2011-06-26 20:50 -0700
  Re: a little c programming that no works!! Ian Collins <ian-news@hotmail.com> - 2011-06-27 16:07 +1200
    Re: a little c programming that no works!! Dirk Zabel <zabel@riccius-sohn.eu> - 2011-06-27 11:37 +0200
      Re: a little c programming that no works!! Ian Collins <ian-news@hotmail.com> - 2011-06-27 22:44 +1200
  Re: a little c programming that no works!! "BartC" <bc@freeuk.com> - 2011-06-27 09:44 +0100
  Re: a little c programming that no works!! Barry Schwarz <schwarzb@dqel.com> - 2011-06-27 06:04 -0700
  Re: a little c programming that no works!! "Heinrich Wolf" <invalid@invalid.invalid> - 2011-06-27 23:54 +0200
    Re: a little c programming that no works!! Lew Pitcher <lpitcher@teksavvy.com> - 2011-06-27 18:11 -0400
    Re: a little c programming that no works!! Barry Schwarz <schwarzb@dqel.com> - 2011-06-27 15:44 -0700
    Re: a little c programming that no works!! Keith Thompson <kst-u@mib.org> - 2011-06-28 22:40 -0700
    Re: a little c programming that no works!! "Heinrich Wolf" <invalid@invalid.invalid> - 2011-06-29 15:44 +0200
      Re: a little c programming that no works!! Keith Thompson <kst-u@mib.org> - 2011-06-29 10:06 -0700

csiph-web