• Re: How to read and write

    From Khelair@VERT/TINFOIL to Deavmi on Fri Nov 27 05:15:00 2015
    Re: How to read and write to files in C?
    By: Deavmi to All on Wed Nov 25 2015 14:04:36

    Could somebidy show me how to read and write to files in C and also explain the code as well as that is very important.

    First command you need to learn (and I believe these are all in stdio.h and/or stdlib.h) is 'fopen()'... did I say command I meant function... If you're on a linux system that has the right manpages 'man fopen' will bring you up a concise little guide on it.
    For reading, so long as it's not to be worked with purely as text, you want to look up next 'fread()', then for writing it's 'fwrite()'. So man fread & man fwrite to see those.
    C is a stickler, too. Make sure you use fclose() when you're done on that filehandle, too.
    If you're not on a linux system you should be able to google these commands along with a capital 'C' and find either the appropriate manpages online or else a good tutorial that covers the applicable material. In fact googling 'C file IO tutorial' might be a good idea (of course I remember it after typing all of this).

    -D/K

    ---
    Borg Burgers: We do it our way; your way is irrelevant.
    þ Synchronet þ Tinfoil Tetrahedron BBS telnet://tinfoil.synchro.net
  • From Deavmi@VERT/TECHQRY to Khelair on Fri Nov 27 21:06:00 2015
    Re: Re: How to read and write to files in C?
    By: Khelair to Deavmi on Fri Nov 27 2015 10:15 am

    Re: How to read and write to files in C?
    By: Deavmi to All on Wed Nov 25 2015 14:04:36

    Could somebidy show me how to read and write to files in C and also explain the code as well as that is very important.

    First command you need to learn (and I believe these are all in stdio.h and/or stdlib.h) is 'fopen()'... did I say command I meant function... If you're on a linux system that has the right manpages 'man fopen' will bring up a concise little guide on it.
    For reading, so long as it's not to be worked with purely as text, you wan to look up next 'fread()', then for writing it's 'fwrite()'. So man fread & man fwrite to see those.
    C is a stickler, too. Make sure you use fclose() when you're done on that filehandle, too.
    If you're not on a linux system you should be able to google these command along with a capital 'C' and find either the appropriate manpages online or else a good tutorial that covers the applicable material. In fact googling file IO tutorial' might be a good idea (of course I remember it after typing all of this).

    -D/K

    Wow, thanks a lot. I never knew you could do man `C function`; thanks a lot. :)

    ---
    þ Synchronet þ TechnoQuarry BBS