Search:

Type: Posts; User: laserlight

Search: Search took 0.29 seconds.

  1. Replies
    21
    Views
    4,307

    The files may vary in size, but they should have...

    The files may vary in size, but they should have complete sets of information. For example, keep to your current code and say, remove the last price from the file. You will probably find that...
  2. Replies
    21
    Views
    4,307

    Checking against the number of format specifiers...

    Checking against the number of format specifiers is usually better in case the input is not well formed (though your results will arguably still be bogus). Notice also that I used %29s instead of...
  3. Replies
    21
    Views
    4,307

    In that case, that loop really should just be...

    In that case, that loop really should just be this:

    while (fscanf(input, "%i%29s%i%i", &info.week, info.name, &info.units, &info.price) == 4)
    {
    week[info.week] += info.units * info.price;
    ...
  4. Replies
    21
    Views
    4,307

    On second thought, it should be more like: ...

    On second thought, it should be more like:

    while (fscanf(input, "%i%29s%i%i", &info.week, info.name, &info.units, &info.price) == 4)
    {
    week[info.week] = info.total = info.units * info.price;...
  5. Replies
    21
    Views
    4,307

    Try: while (fscanf(input, "%i%29s%i%i",...

    Try:

    while (fscanf(input, "%i%29s%i%i", &info.week, info.name, &info.units, &info.price) == 4)
    {
    week[info.week] += info.units * info.price;
    info.total = week[info.week];
    if...
  6. Replies
    21
    Views
    4,307

    Eh, this looks wrong: input = fopen(argv[1],...

    Eh, this looks wrong:

    input = fopen(argv[1], "r") ;
    output = fopen(argv[2], "w") ;

    if(( fopen(argv[1], "r")) == NULL)
    {
    printf("Sorry, this file cannot be opened.\n") ;
    ...
  7. Replies
    21
    Views
    4,307

    Yes, though if it is too long, show the smallest...

    Yes, though if it is too long, show the smallest and simplest compilable program that demonstrates the problem.
Results 1 to 7 of 7