Author Topic: C Programming Books Or Tutorials?  (Read 8773 times)

0 Members and 1 Guest are viewing this topic.

Offline _Nicco_

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 173
  • Rating: +6/-0
    • View Profile
C Programming Books Or Tutorials?
« on: September 19, 2012, 02:04:08 am »
Hey everyone.  I'd like to know if anyone would recommend any books on C programming.  I just started wanting to program my calculator but I've already had programming experience with Java ( I took a class on it at school).  I want to get going on C programming but there are so many different books on it.  Should I get a book or just watch tutorials?  What tutorials are good?  I have a Ti-Nspire CX CAS and would like to get some programs running on it so I really want to learn C as soon as possible.

Thanks
They say that your signature is supposed to go here...

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: C Programming Books Or Tutorials?
« Reply #1 on: September 19, 2012, 02:13:29 am »
Quote
I have a Ti-Nspire CX CAS and would like to get some programs running on it so I really want to learn C as soon as possible.
That's a courageous choice of yours - most people give up on the closed CX CAS platform and use something more open, such as a computer, a Raspberry Pi (significantly more powerful than a Nspire but four to six times cheaper), an Ordroid-X, etc :)

In French, the Site du Zéro tutorials can be a good source of information; I don't know which are the best English-speaking resources for learning C.
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline SpiroH

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 729
  • Rating: +153/-23
    • View Profile
Re: C Programming Books Or Tutorials?
« Reply #2 on: September 19, 2012, 07:47:19 am »
I'd like to know if anyone would recommend any books on C programming.  I want to get going on C programming but there are so many different books on it.  Should I get a book or just watch tutorials?  What tutorials are good?
1.Start with a good tutorial, this one, for example: http://computer.howstuffworks.com/c23.htm/printable; 2. Do some simple programming (there are tons of C source code samples in the net); 3. If you don't get bored, buy a good book (scan its contents beforehand) it will help you to clear up some doubts. Here is a good and cheap (<$10) one: http://www.amazon.com/Book-C-Al-Kelley/dp/0805368604. Yeah, it looks old (1984) but so is the language (1972): http://en.wikipedia.org/wiki/C_language
LBNL, do not wait for the best choice, maybe it will never come up. So the answer to your question is: you'll need both: tutorial(s)+book(s). Good readings.


Offline _Nicco_

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 173
  • Rating: +6/-0
    • View Profile
Re: C Programming Books Or Tutorials?
« Reply #3 on: September 19, 2012, 07:04:52 pm »
That's a courageous choice of yours - most people give up on the closed CX CAS platform and use something more open, such as a computer, a Raspberry Pi (significantly more powerful than a Nspire but four to six times cheaper), an Ordroid-X, etc :)

In French, the Site du Zéro tutorials can be a good source of information; I don't know which are the best English-speaking resources for learning C.

Thanks for the reference but I don't speak French.  I chose the CX CAS because I use it nearly every day for school but I'm still planning on getting a raspberry pi. :)

1.Start with a good tutorial, this one, for example: http://computer.howstuffworks.com/c23.htm/printable; 2. Do some simple programming (there are tons of C source code samples in the net); 3. If you don't get bored, buy a good book (scan its contents beforehand) it will help you to clear up some doubts. Here is a good and cheap (<$10) one: http://www.amazon.com/Book-C-Al-Kelley/dp/0805368604. Yeah, it looks old (1984) but so is the language (1972): http://en.wikipedia.org/wiki/C_language
LBNL, do not wait for the best choice, maybe it will never come up. So the answer to your question is: you'll need both: tutorial(s)+book(s). Good readings.


I'll probably end up buying the book but for now I'll just work on the tutorials.  An what do you mean by LBNL, I don't think that I have ever seen that before?  Thanks
They say that your signature is supposed to go here...

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: C Programming Books Or Tutorials?
« Reply #4 on: September 19, 2012, 09:07:51 pm »
Actually, the best way to learn C is to get computer science courses at college, other than that, a good tutorial can get you started and if you learn how to read documentation and/or .h files, the sky is the limit. Plus, most languages are loosely based on C, so if you learn C or another language, it will be easy to get started on the other languages.

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline _Nicco_

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 173
  • Rating: +6/-0
    • View Profile
Re: C Programming Books Or Tutorials?
« Reply #5 on: September 19, 2012, 09:29:02 pm »
Actually, the best way to learn C is to get computer science courses at college, other than that, a good tutorial can get you started and if you learn how to read documentation and/or .h files, the sky is the limit.

I'm already taking a course on Java at my HighSchool but they don't offer C.  What are .h files?  I know that you create .c files when programming in c but what's .h?

Thanks
They say that your signature is supposed to go here...

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: C Programming Books Or Tutorials?
« Reply #6 on: September 19, 2012, 09:33:53 pm »
.h files are headers containing function declarations. You'll want to include them in your .c file (like import in Java) if you want to use their corresponding libraries.

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline CompSystems

  • LV3 Member (Next: 100)
  • ***
  • Posts: 68
  • Rating: +7/-4
  • HP48GX,HP50G and TInspireCAS Calculator Programmer
    • View Profile
    • HP48GX,HP50G and TInspireCAS Calculator Programmer
Re: C Programming Books Or Tutorials?
« Reply #7 on: October 01, 2012, 12:55:44 pm »
Sp:Un excelente libro de C y C++ con varios ejemplos de fisica
Eng: An excellent book for C and C + + with several examples of physical

http://books.google.com.co/books?id=E1CMxC4KKSYC&printsec=frontcover&hl=es#v=onepage&q&f=false
« Last Edit: October 02, 2012, 10:58:39 am by CompSystems »

Offline _Nicco_

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 173
  • Rating: +6/-0
    • View Profile
Re: C Programming Books Or Tutorials?
« Reply #8 on: October 01, 2012, 10:48:19 pm »
Un excelente libro de C y C++ con varios ejemplos de fisica

http://books.google.com.co/books?id=E1CMxC4KKSYC&printsec=frontcover&hl=es#v=onepage&q&f=false

Disculpe pero las reglas dicen que debemos de hablar en ingles.  Mi espanol no es tan bueno pero todavia lo puedo probar.   Gracias por la idea.  Si usted puede hablar en ingles porfavor escriba en ingles.

Translation:
Sorry but the rules say that we need to speak in English.  My Spanish is not that good  but I can still give it a try.  Thanks for the idea.  If you can speak English please write in English.
They say that your signature is supposed to go here...

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: C Programming Books Or Tutorials?
« Reply #9 on: October 02, 2012, 01:16:03 am »
Is Technoplaza any good for Nspire stuff? http://www.technoplaza.net/

It's a TI-89/92+/v200 tutorial to program in C, but it's very old.

Offline CompSystems

  • LV3 Member (Next: 100)
  • ***
  • Posts: 68
  • Rating: +7/-4
  • HP48GX,HP50G and TInspireCAS Calculator Programmer
    • View Profile
    • HP48GX,HP50G and TInspireCAS Calculator Programmer
Re: C Programming Books Or Tutorials?
« Reply #10 on: October 02, 2012, 12:25:36 pm »
GCC4TI or C compiler for TInspire, contains a library that generates dialog boxes?

for TIGCC info: Lesson 10: File I/O
http://www.technoplaza.net/programming/lesson10.php

Example
Code: [Select]
// comment this next line out for TI-92+/V200 support
#define USE_TI89

#ifndef USE_TI89
    #define USE_TI92PLUS
    #define USE_V200
#endif

#include <dialogs.h>
#include <ctype.h>
#include <string.h>
#include <mem.h>
#include <stdio.h>
#include <kbd.h>
#include <stdlib.h>
#include <alloc.h>
#include <args.h>
#include <menus.h>

// the minus and the negative sign have different values, though they look nearly identical
#define DASH    173

#ifdef USE_TI89
    enum DialogConstants    {DLG_WIDTH = 140, DLG_HEIGHT = 85};
#else
    enum DialogConstants    {DLG_WIDTH = 200, DLG_HEIGHT = 90};
#endif

enum ErrorConstants {FILEIO1,FILEIO2,FILEIO3,FILEIO4,FILEIO5,MEMERR1,MEMERR2,
             DATA_ERROR,DOB_ERROR,HEIGHT_ERROR,WEIGHT_ERROR};
enum MenuConstants  {MENU_DATA = 1000,MENU_READ,MENU_WRITE,MENU_PRINT,MENU_EXIT};

const char *error[] = {"File I/O Error","Unable to Open File!",
            "Unable to read or write data to file",
            "File I/O Status","Success!",
            "Memory Error","Not enough free memory!",
            "Data Error","DOB Must be MM-DD-YYYY",
            "Height must be between 100 and 250 cm",
            "Weight must be between 35 and 180 kg"};

typedef struct {
    char name[15];
    short int height;
    short int weight;
    char dob[11];
} PERSON;

inline void dlgError(short int title, short int msg) {
    DlgMessage((char *)error[title],(char *)error[msg],BT_OK,BT_NONE);
}

// check for valid date of birth (MM-DD-YYYY)
short int isValidDOB(const unsigned char *dob) {
    if (isdigit(dob[0]) && isdigit(dob[1]) && (dob[2] == '-' || dob[2] == DASH) &&
        isdigit(dob[3]) && isdigit(dob[4]) && (dob[5] == '-' || dob[5] == DASH) &&
        isdigit(dob[6]) && isdigit(dob[7]) && isdigit(dob[8]) && isdigit(dob[9])) {

        return TRUE;
    }

    return FALSE;
}

// check for valid height (in centimeters)
short int isValidHeight(const short int height) {
    if (height > 100 && height < 250) {
        return TRUE;
    }

    return FALSE;
}

// check for valid weight (in kilograms)
short int isValidWeight(const short int weight) {
    if (weight > 35 && weight < 180) {
        return TRUE;
    }

    return FALSE;
}

void initPerson(PERSON *p) {
    // terminate the person strings
    p->name[0] = 0;
    p->dob[0] = 0;

    // enter generic person information
    strcpy(p->name,"Dominic Silver");
    strcpy(p->dob,"06-02-1972");
    p->height = 190;
    p->weight = 87;
}

void formatRequestString(char *temp, PERSON *p) {
    // erase the buffer string
    memset(temp,0,34*sizeof(char));

    // format the buffer string so the dialog box will have default values
    sprintf(temp,"%-15s%-11s%03hd %03hd",p->name,p->dob,p->height,p->weight);

    // add string separators
    temp[14] = 0;
    temp[25] = 0;
    temp[29] = 0;
    temp[33] = 0;
}

short int getData(PERSON *p, char *buffer) {
    HANDLE dlg = H_NULL;
    int done = FALSE;
    char *token;

    // create the dialog box
    if ((dlg = DialogNewSimple(DLG_WIDTH,DLG_HEIGHT)) != H_NULL) {
        // format the dialog box
        DialogAddTitle(dlg,"Personal Information",BT_OK,BT_NONE);
        DialogAddRequest(dlg,5,15,"Name:",0,14,18);
        DialogAddRequest(dlg,5,25,"DOB:",15,10,18);
        DialogAddRequest(dlg,5,35,"Height (cm):",26,3,5);
        DialogAddRequest(dlg,5,45,"Weight (kg):",30,3,5);

        while (!done) {
            // loop until the user presses ENTER
            while (DialogDo(dlg,CENTER,CENTER,buffer,NULL) != KEY_ENTER);

            // grab the name from the string buffer
            token = buffer;
            p->name[0] = 0;
            strcpy(p->name,token);

            // grab the DOB from the string buffer
            token = buffer + 15;
            p->dob[0] = 0;
            strcpy(p->dob,token);

            // grab the height from the string buffer
            token += 11;
            p->height = atoi(token);

            // grab the weight from the string buffer
            token += 4;
            p->weight = atoi(token);

            // we're done unless we fail one of our validity tests
            done = TRUE;

            // check for valid DOB entry (MM/DD/YYYY)
            if (!isValidDOB((const unsigned char *)p->dob)) {
                dlgError(DATA_ERROR,DOB_ERROR);
                done = FALSE;
            }

            // check for reasonable valid height
            if (!isValidHeight((const short int)p->height)) {
                dlgError(DATA_ERROR,HEIGHT_ERROR);
                done = FALSE;
            }

            // check for reasonable valid weight
            if (!isValidWeight((const short int)p->weight)) {
                dlgError(DATA_ERROR,WEIGHT_ERROR);
                done = FALSE;
            }
        }

        // free the memory used by the dialog
        HeapFree(dlg);
    } else {
        dlgError(MEMERR1,MEMERR2);
        return FALSE;
    }

    return TRUE;
}

short int writeData(PERSON *p) {
    FILE *f = NULL;
    short int fileio = TRUE;

    // open file for writing
    if ((f = fopen("TESTFILE","wb")) == NULL) {
        dlgError(FILEIO1,FILEIO2);
        fileio = FALSE;
    } else {
        // write structure data to the file
        if (fwrite(p,sizeof(PERSON),1,f) != 1) {
            dlgError(FILEIO1,FILEIO3);
            fileio = FALSE;
        }

        // append the file ID tag
        fputc(0,f);
        fputs("FIO",f);
        fputc(0,f);
        fputc(OTH_TAG,f);

        // close the file
        fclose(f);
    }

    return fileio;
}

short int readData(PERSON *p) {
    FILE *f = NULL;
    short int fileio = TRUE;

    // open file for reading in binary mode
    if ((f = fopen("TESTFILE","rb")) == NULL) {
        dlgError(FILEIO1,FILEIO2);
        fileio = FALSE;
    } else {
        // read data from file into PERSON structure
        if (fread(p,sizeof(PERSON),1,f) != 1) {
            dlgError(FILEIO1,FILEIO3);
            fileio = FALSE;
        }

        // close the file
        fclose(f);
    }

    return fileio;
}

void printData(PERSON *p) {
    char name[25],dob[20],height[20],weight[20];
    HANDLE dlg = H_NULL;

    if ((dlg = DialogNewSimple(DLG_WIDTH,DLG_HEIGHT)) != H_NULL) {
        // create the personal information strings
        sprintf(name,"Name: %s",p->name);
        sprintf(dob,"DOB: %s",p->dob);
        sprintf(height,"Height: %hd cm",p->height);
        sprintf(weight,"Weight: %hd kg",p->weight);

        // format the dialog box
        DialogAddTitle(dlg,"Personal Information",BT_OK,BT_NONE);
        DialogAddText(dlg,5,15,name);
        DialogAddText(dlg,5,25,dob);
        DialogAddText(dlg,5,35,height);
        DialogAddText(dlg,5,45,weight);

        // display the dialog box
        DialogDo(dlg,CENTER,CENTER,NULL,NULL);

        HeapFree(dlg);
    }
}

void _main(void) {
    char buffer[34];
    PERSON p;
    short int done = 0, option = MENU_DATA;
    HANDLE dlg = H_NULL, menu = H_NULL;

    // initialize the person structure
    initPerson(&p);

    // format the request buffer string
    formatRequestString(buffer,&p);

    if ((dlg = DialogNewSimple(DLG_WIDTH,DLG_HEIGHT)) == H_NULL) {
        dlgError(MEMERR1,MEMERR2);
        return;
    }

    if ((menu = PopupNew(NULL,0)) == H_NULL) {
        dlgError(MEMERR1,MEMERR2);
        HeapFree(dlg);
        return;
    }

    // create Dialog Menu
    PopupAddText(menu,-1,"Enter new Data",MENU_DATA);
    PopupAddText(menu,-1,"Read Data from File",MENU_READ);
    PopupAddText(menu,-1,"Save Data to File",MENU_WRITE);
    PopupAddText(menu,-1,"Print Information",MENU_PRINT);
    PopupAddText(menu,-1,"Exit",MENU_EXIT);

    DialogAddTitle(dlg,"Main Menu",BT_OK,BT_CANCEL);
    DialogAddPulldown(dlg,5,15,"Selection:",menu,0);

    do {
        if (DialogDo(dlg,CENTER,CENTER,NULL,&option) != KEY_ENTER) {
            option = MENU_EXIT;
        }

        switch (option) {
            case MENU_DATA:
                getData(&p,buffer);
                printData(&p);
                break;
            case MENU_READ:
                if (readData(&p)) {
                    dlgError(FILEIO4,FILEIO5);
                    formatRequestString(buffer,&p);
                    printData(&p);
                }
                break;
            case MENU_WRITE:
                if (writeData(&p)) {
                    dlgError(FILEIO4,FILEIO5);
                }
                break;
            case MENU_PRINT: printData(&p); break;
            case MENU_EXIT: done = TRUE; break;
        }
    } while (!done);

    // free the memory used by the dialog box and selector menu
    HeapFree(menu);
    HeapFree(dlg);
}
« Last Edit: October 02, 2012, 01:30:11 pm by CompSystems »

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: C Programming Books Or Tutorials?
« Reply #11 on: October 02, 2012, 01:21:09 pm »
The OS of both TI-68k calculators and Nspire calculators contains a whole lot of built-in code for dialogs and menus, indeed. The one of the Nspire is only partially documented.
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline CompSystems

  • LV3 Member (Next: 100)
  • ***
  • Posts: 68
  • Rating: +7/-4
  • HP48GX,HP50G and TInspireCAS Calculator Programmer
    • View Profile
    • HP48GX,HP50G and TInspireCAS Calculator Programmer
Re: C Programming Books Or Tutorials?
« Reply #12 on: October 02, 2012, 01:29:45 pm »
Sorry for my bad English. GOOGLE translations

Docs of Dialog Boxes for GCC4TI where? and npsire?  :-[

For me the most valuable of the Texas Instruments calculators  is your CAS.

I think the most important to have multiple languages ​​on a calculator (Lua, C, etc), is that they can interact with the CAS, otherwise would have to develop a library of symbolic algebra "CAS.c" that is not the purpose, because TI have many years of development, from the TIderive

... for example from a program in C or LUA, I can call as the derivative of an expression and then capture the result?.

I want to create a programs with dialog boxes that operate the CAS. Which was not the reason of TI developers not to incorporate dialogue boxes?

I am not an expert programmer, but make a library that generates dialog boxes for HP50 calculators, in RPN language can interact with the HP50_CAS

http://www.hpcalc.org/details.php?id=7282

« Last Edit: October 02, 2012, 02:20:43 pm by CompSystems »

Offline blue_bear_94

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 801
  • Rating: +25/-35
  • Touhou Enthusiast / Former Troll / 68k Programmer
    • View Profile
Re: C Programming Books Or Tutorials?
« Reply #13 on: December 05, 2012, 05:46:26 pm »
Is Technoplaza any good for Nspire stuff? http://www.technoplaza.net/

It's a TI-89/92+/v200 tutorial to program in C, but it's very old.

I don't think so; however, it may be useful for programming in C in general. (I used this tutorial for C on my TI-89 Titanium.)
Due to dissatisfaction, I will be inactive on Omnimaga until further notice. (?? THP hasn't been much success and there's also the CE. I might possibly be here for a while.)
If you want to implore me to come back, or otherwise contact me, I can be found on GitHub (bluebear94), Twitter (@melranosF_), Reddit (/u/Fluffy8x), or e-mail (if you know my address). As a last resort, send me a PM on Cemetech (bluebear94) or join Touhou Prono (don't be fooled by the name). I've also enabled notifications for PMs on Omnimaga, but I don't advise using that since I might be banned.
Elvyna (Sunrise) 4 5%
TI-84+SE User (2.30 2.55 MP 2.43)
TI-89 Titanium User (3.10)
Casio Prizm User? (1.02)
Bag  東方ぷろの

Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: C Programming Books Or Tutorials?
« Reply #14 on: December 05, 2012, 08:22:14 pm »
if you're looking for a C book, then this one is pretty much the de-facto for introductory classes (and it even throws in some c++ at the end). there are plenty of older versions available around the internets for very low prices, too =)