Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: C language newb question

  1. #1

    Question C language newb question

    i have just started learning assembly and c could anybody please tell some good books on them especially C i am having problem in c i am new here does any body know good thread on AO about C

  2. #2
    Senior Member
    Join Date
    Nov 2003
    Posts
    285
    Hi

    "let us C by yeshvant kanetker" is the best book for newbs starting C

    and "IBM PC Assembly Language and Programming by Peter Abel" for assembly

  3. #3
    hi wolverine
    i know a bit of C , i am not a absolute newb in C. i want a good book that explains Disk I/O in C

  4. #4
    Senior Member
    Join Date
    Nov 2003
    Posts
    285
    I think the Book " let us C" is good for both students and advanced programmer alike i always refer to the for C

  5. #5
    could u help me out here i have this school assignment coming could u please explain Disk I/O a bit give example code or something

  6. #6
    AO Antique pwaring's Avatar
    Join Date
    Aug 2001
    Posts
    1,409
    I'd advise purchasing/borrowing "The C Programming Language" (Kernighan and Ritchie) otherwise known as the K&R book. It covers I/O for files as well as low-level access in Unix and is *the* C reference book.
    Paul Waring - Web site design and development.

  7. #7
    Senior Member
    Join Date
    Nov 2003
    Posts
    285
    this program will read a file and count how many characters, spaces and newlines are present in a file

    [quote]

    #include "stdio.h"

    void main()
    {
    FILE *fp;
    char ch;
    int nol=0, not=0,nos=0,noc=0;

    fp=fopen("Test","r");

    while(1)
    {
    ch=fgetc(fp);

    if(ch==EOF)
    break;
    noc++;

    if(ch=="")
    nob++;

    if(ch='\n')
    nol++;

    if(ch=='\t')
    not++;

    }

    fclose(fp);

    printf("\nNumber of characters=%d",noc);
    printf("\nNumber of blanks=%d",noc);
    printf("\nNumber of tabs=%d",noc);
    printf("\nNumber of lines=%d",noc);
    }[\quote]


    haven't compiled but it should work let me know if it dosen't or u don't understand anything

  8. #8
    Originally posted here by w0lverine

    FILE *fp;

    what is this FILE

  9. #9
    Senior Member
    Join Date
    Nov 2003
    Posts
    285
    Originally posted here by neemitjamwal
    what is this FILE
    before a file could be read or written it must be opened. opening a file establishes a link between the program and the operationg system. the link between our prog and the OS is a structure called FILE which has been defined in the header "stdio.h". we request the OS to open a file and what we get back is a pointer to the structure FILE. that is why we make the following dec.


    FILE *fp;

  10. #10
    i can understand the rest of the code except
    fp=fopen("Test","r");
    fp is the file pointer what does fopen() do

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •