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


Groups > comp.lang.c > #3268

Re: puzzling error

From August Karlstrom <fusionfile@gmail.com>
Newsgroups comp.lang.c
Subject Re: puzzling error
Date 2011-05-05 15:58 +0200
Organization A noiseless patient Spider
Message-ID <ipuaf1$6jk$1@dont-email.me> (permalink)
References <4dc29b93$0$5067$bbae4d71@news.suddenlink.net>

Show all headers | View raw


On 2011-05-05 14:44, Bill Cunningham wrote:
>      I am not quite sure what is going on here but this is my tested and
> compiled code. As written below at compile time I get this warning.
>
> p.c: In function `main':
> p.c:9: warning: assignment makes pointer from integer without a cast
>
> I don't see the int in this code.
>
> #include<stdio.h>
> #include<string.h>
>
> int main(void)
> {
>      char p[] = "hello to all";
>      char *a;
>      printf("%s\n", p);
>      printf("%s\n", a = strfry(p)); //error on this line.
>      return 0;
> }
>
> strfry() is a GNU extension. It takes a char* as is sole argument and
> returns a char*.  Now if I change that char p[] to a char *p I get a
> segmentation fault. What's up with that?

The clang compiler will give you a bit more information (even without 
warnings enabled):

$ clang test.c
test.c:9:24: warning: implicit declaration of function 'strfry' is 
invalid in
       C99 [-Wimplicit-function-declaration]
     printf("%s\n", a = strfry(p)); //error on this line.
                        ^
test.c:9:22: warning: incompatible integer to pointer conversion 
assigning to
       'char *' from 'int'
     printf("%s\n", a = strfry(p)); //error on this line.
                      ^ ~~~~~~~~~
2 warnings generated.


/August

-- 
The competent programmer is fully aware of the limited size of his own 
skull. He therefore approaches his task with full humility, and avoids 
clever tricks like the plague. --Edsger Dijkstra

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


Thread

puzzling error "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-05 08:44 -0400
  Re: puzzling error Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-05-05 13:56 +0100
    Re: puzzling error "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-05 12:11 -0400
      Re: puzzling error Keith Thompson <kst-u@mib.org> - 2011-05-05 09:26 -0700
        Re: puzzling error "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-05 13:26 -0400
        Re: puzzling error Chad <cdalten@gmail.com> - 2011-05-05 11:34 -0700
        Re: puzzling error "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-05 14:52 -0400
        Re: puzzling error Paul N <gw7rib@aol.com> - 2011-05-05 13:39 -0700
          Re: puzzling error Keith Thompson <kst-u@mib.org> - 2011-05-05 13:54 -0700
        Re: puzzling error Seebs <usenet-nospam@seebs.net> - 2011-05-05 20:38 +0000
          Re: puzzling error Keith Thompson <kst-u@mib.org> - 2011-05-05 14:11 -0700
          Re: puzzling error Angel <angel+news@spamcop.net> - 2011-05-05 23:40 +0000
      Re: puzzling error Kenneth Brody <kenbrody@spamcop.net> - 2011-05-05 13:55 -0400
        Re: puzzling error "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-05 14:04 -0400
          Re: puzzling error Kenneth Brody <kenbrody@spamcop.net> - 2011-05-09 13:26 -0400
        Re: puzzling error Keith Thompson <kst-u@mib.org> - 2011-05-05 11:31 -0700
    Re: puzzling error Keith Thompson <kst-u@mib.org> - 2011-05-05 09:06 -0700
      Re: puzzling error "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-05 12:30 -0400
      Re: puzzling error Kenneth Brody <kenbrody@spamcop.net> - 2011-05-05 13:40 -0400
      Re: puzzling error Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-05-05 21:32 +0100
    Re: puzzling error "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-05 13:34 -0400
      Re: puzzling error Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-05-05 21:38 +0100
        Re: puzzling error "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-06 02:39 -0400
          Re: puzzling error Keith Thompson <kst-u@mib.org> - 2011-05-05 23:40 -0700
  Re: puzzling error Ike Naar <ike@sverige.freeshell.org> - 2011-05-05 13:01 +0000
    Re: puzzling error "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-05 12:05 -0400
      Re: puzzling error Angel <angel+news@spamcop.net> - 2011-05-05 16:23 +0000
    Re: puzzling error Keith Thompson <kst-u@mib.org> - 2011-05-05 09:08 -0700
  Re: puzzling error Marc Boyer <Marc.Boyer@cert.onera.fr.invalid> - 2011-05-05 13:02 +0000
    Re: puzzling error "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-05 12:34 -0400
      Re: puzzling error "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-05 12:35 -0400
      Re: puzzling error "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-05 12:40 -0400
      Re: puzzling error Kenneth Brody <kenbrody@spamcop.net> - 2011-05-05 14:08 -0400
        Re: puzzling error Keith Thompson <kst-u@mib.org> - 2011-05-05 11:35 -0700
          Re: puzzling error Angel <angel+news@spamcop.net> - 2011-05-05 18:54 +0000
            OT: man strfry (was Re: puzzling error) Kenneth Brody <kenbrody@spamcop.net> - 2011-05-09 13:33 -0400
              Re: man strfry (was Re: puzzling error) "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-11 14:30 -0400
    Re: puzzling error "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-05 13:13 -0400
      Re: puzzling error Kenneth Brody <kenbrody@spamcop.net> - 2011-05-05 14:13 -0400
        Re: puzzling error "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-05 14:27 -0400
          Re: puzzling error "Joachim Schmitz" <nospam.jojo@schmitz-digital.de> - 2011-05-07 09:59 +0200
            Re: puzzling error Keith Thompson <kst-u@mib.org> - 2011-05-07 11:20 -0700
  Re: puzzling error August Karlstrom <fusionfile@gmail.com> - 2011-05-05 15:58 +0200
  Re: puzzling error "osmium" <r124c4u102@comcast.net> - 2011-05-05 10:38 -0500
    Re: puzzling error "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-05 12:03 -0400
      Re: puzzling error Joe Wright <joewwright@comcast.net> - 2011-05-05 13:19 -0400
      Re: puzzling error Kenneth Brody <kenbrody@spamcop.net> - 2011-05-05 13:34 -0400
        Re: puzzling error "osmium" <r124c4u102@comcast.net> - 2011-05-05 12:54 -0500
        Re: puzzling error "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-05 14:08 -0400
    Re: puzzling error "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-05 12:06 -0400
    Re: puzzling error Keith Thompson <kst-u@mib.org> - 2011-05-05 09:11 -0700
      Re: puzzling error "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-05 12:36 -0400
    Re: puzzling error Kenneth Brody <kenbrody@spamcop.net> - 2011-05-05 13:33 -0400
  Re: puzzling error Angel <angel+news@spamcop.net> - 2011-05-05 16:01 +0000
    Re: puzzling error "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-05 12:09 -0400
      Re: puzzling error Angel <angel+news@spamcop.net> - 2011-05-05 16:19 +0000
        Re: puzzling error "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-05 12:28 -0400
          Re: puzzling error "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-05 12:42 -0400
            Re: puzzling error "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-05 13:16 -0400
      Re: puzzling error Kenneth Brody <kenbrody@spamcop.net> - 2011-05-05 13:41 -0400

csiph-web