Thread: quick help

  1. #1
    Registered User
    Join Date
    Apr 2002

    quick help

    Is there a way to type cast the first argument of these functions ?

    fputs(const *char, FILE *)

    fgets(const *char, FILE *)

    thanks in advance

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Visalia, CA, USA
    I'm not sure exactly what you are asking but I'll give it a go anyway. You can do this:
    int break_your_program;
    fgets((char *)&break_your_program, stdin);
    //or something similar to this
    But it is more likely in the real world that you would be doing something more like this:
    long could_break_your_program = ('%' << 24) | ('l' << 16) | ('d' << 8);
    fgets((char *)&could_break_your_program, stdin);
    However, I still would question why someone would even do the second one.

  3. #3
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Bangalore, India
    1.) Type cast to what? If another 'const' type, it's fine.
    2.) I doubt fgets()'s first argument is of the type specified [Talking about the standard stdio.h - fgets()]

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    fgets has 3 parameters as well
    char *fgets(char *s, size_t n, FILE *stream);

    All the const means in the fputs case is that it tells you that fputs will not modify what you pass to it. It does not mean that what you pass to it has to be const in the first place

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Do you know...
    By davejigsaw in forum C++ Programming
    Replies: 1
    Last Post: 05-10-2005, 10:33 AM
  2. recursive quick sort - stack overflow
    By Micko in forum C Programming
    Replies: 9
    Last Post: 01-01-2005, 05:51 PM
  3. Questions on basic Quick Sort
    By Weng in forum C++ Programming
    Replies: 4
    Last Post: 12-16-2003, 10:06 AM
  4. Quick Sort Help
    By NavyBlue in forum C Programming
    Replies: 1
    Last Post: 03-02-2003, 10:34 PM
  5. Replies: 0
    Last Post: 04-30-2002, 07:24 PM