declare function inside fork()

This is a discussion on declare function inside fork() within the C Programming forums, part of the General Programming Boards category; Originally Posted by master5001 It means you are doing something like: [blah] Absolutely not my friend. Here is the exact ...

  1. #16
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by master5001 View Post

    It means you are doing something like:
    [blah]
    Absolutely not my friend. Here is the exact line

    sprintf(messg,"Can't unlink %s",sckt);

    Where is the extra argument???
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  2. #17
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    sprintf(messg,"Can't unlink %s",sckt);
    Last edited by master5001; 10-11-2008 at 02:30 PM.

  3. #18
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Careful on those, MK27. Its a mistake all of us can easily make. Remember that printf() works with the output buffer. sprint() is the one that prints to strings.
    Last edited by master5001; 10-11-2008 at 02:29 PM.

  4. #19
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Even at that, I would recommend using snprintf(). Which helps prevent buffer overflows.

    Remember, only you can prevent buffer overflows.

  5. #20
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by master5001 View Post
    Its a mistake all of us can easily make.
    I bet.

    Code:
    Function: int sprintf (char *s, const char *template, ...)
        This is like printf, except that the output is stored in the character array s 
    instead of written to a stream. A null character is written to mark the end of the string.
    Does this mean I am a prisoner of GNU forever?
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  6. #21
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    MK27 can you post a compilable snippet?

  7. #22
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by robwhit View Post
    MK27 can you post a compilable snippet?
    of what?

    ps. it wasn't a scoping issue
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  8. #23
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Of your sprintf problem.

  9. #24
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by robwhit View Post
    Of your sprintf problem.
    I didn't understand that there was one.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  10. #25
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Umm... ok...

  11. #26
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,602
    Well, obviously there is one since you get a warning?
    And btw master5001, you know there's an edit button, right?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  12. #27
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Elysia View Post
    Well, obviously there is one since you get a warning?
    No. For example, my compiler (gcc 4.1.2) gives an "assignment makes pointer from integer without a cast" warning whenever strcasestr
    is used, no matter how -- guarrenteed. That's an erroneous warning.

    (master5001 knows this and would fancy himself a mindf#@er)
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  13. #28
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Quote Originally Posted by Elysia View Post
    Well, obviously there is one since you get a warning?
    And btw master5001, you know there's an edit button, right?
    Yeah but I was hungry and ready to head home... So I figured people would overlook my spamming.

    Quote Originally Posted by MK27
    Does this mean I am a prisoner of GNU forever?
    Not at all. sprintf() is a C standard function. strcasestr() on the otherhand is a GNU extention. I use it anyway... Microsoft provides a lot of functions similar to the GNU extentions that one can simply #define as the GNU names of the functions. I know that is not your issue, MK27. But there are a lot of M$ folks floating around.

    Can you post an example of code that gives you that error reguardless? Por favor.

    [edit]Hey, are you trying to pass a socket as a string? That would issue a warning too. Though typically it would not be this specific warning.[/edit]
    Last edited by master5001; 10-11-2008 at 02:31 PM.

  14. #29
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by master5001 View Post
    strcasestr() on the otherhand is a GNU extention.

    Can you post an example of code that gives you that error reguardless? Por favor.
    found = strcasestr(content, fthis);

    But gcc is a GNU compiler...

    Quote Originally Posted by master5001 View Post
    Hey, are you trying to pass a socket as a string? That would issue a warning too. Though typically it would not be this specific warning.
    A filename that aspires to sockethood.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  15. #30
    The larch
    Join Date
    May 2006
    Posts
    3,573
    And how are content, fthis and found declared?
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

Page 2 of 3 FirstFirst 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 04-11-2009, 09:44 AM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. C++ compilation issues
    By Rupan in forum C++ Programming
    Replies: 1
    Last Post: 08-22-2005, 05:45 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21