Thread: Files

  1. #1
    Registered User unixOZ's Avatar
    Join Date
    Feb 2002
    Posts
    91

    Files

    I have the following in a file
    code name amount_sold amount_available
    for example:

    457654 rice 84 10000
    875 corn 44 1455

    I need to ask the user what product (code) he wants to change the amount sold, and it exists (search by code) change the amount sold and therefore the amount available.
    Ive already coded the part where the user inputs the code and checks if it exists. How ever, I cant seem to be able to put the amount available in a char * so I can control it. If anyone could help me I would be most grateful
    http://www.igloo.cl/~unixoz

  2. #2
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,164

    Re: Files

    Originally posted by unixOZ
    I have the following in a file
    code name amount_sold amount_available
    for example:

    457654 rice 84 10000
    875 corn 44 1455

    I need to ask the user what product (code) he wants to change the amount sold, and it exists (search by code) change the amount sold and therefore the amount available.
    Ive already coded the part where the user inputs the code and checks if it exists. How ever, I cant seem to be able to put the amount available in a char * so I can control it. If anyone could help me I would be most grateful
    use strcpy to put the data in a char*

    If that's not enough then:

    For the hundredth time this week alone, why not post the code that you've written to solve your problem so we can help you. We have no idea where to start based on the code you've already written.


    Click on the "Read This First" link prominately displayed at the top of this board for further info about how to get help (or click here: http://cboard.cprogramming.com/annou...p?s=&forumid=4 )
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  3. #3
    Registered User unixOZ's Avatar
    Join Date
    Feb 2002
    Posts
    91
    I have the following to put all the codes in a char **codigos_disponibles

    while ((c=fgetc(fd)) != EOF) {
    if (c == ' ')
    espacio = 1;

    if (espacio == 0) {
    sprintf(x1, "%c", c);
    strcat(x, x1);
    }

    if (c == '\n') {
    espacio = 0;
    *codigos_disponibles++ = x;
    x = (string)calloc(8, sizeof(string));
    }
    }

    for(i=0;i<4;i++)
    if(strcmp(elemento, *--codigos_disponibles) == 0)
    encontrado = TRUE;
    http://www.igloo.cl/~unixoz

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ressources files
    By mikahell in forum Windows Programming
    Replies: 4
    Last Post: 06-19-2006, 06:50 AM
  2. add source files to embedded VC 4.0
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2006, 03:28 AM
  3. *.cpp and *.h files understanding
    By ElastoManiac in forum C++ Programming
    Replies: 4
    Last Post: 06-11-2006, 04:45 AM
  4. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:46 AM
  5. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 02:41 PM