0

What i have done is using the first set of code i extracted the data and put it into a new file so it is only the values

This is my input file for first set of code:

original input

This is my input file for second set of code which is my main problem:

second set of input code

then in second set of code is where the new file is being read so it outputs the numbers using fgetc, how could I now apply a simple formula using this? specifically the formula would be turning any 10 value into a 0 value i tried that and since fgetc is unsigned char i try using the binary number for 10 in the if statement

this is my code so far:

#include<stdio.h> 

int main() 
{ 
    FILE* ptr = fopen("Data.txt","r"); 
    if (ptr==NULL) 
    { 
        printf("no such file."); 
        return 0; 
    } 

    FILE*fp = fopen("/data flow/NEWdata.txt", "w+");

        int x;
  int count=0;
    char buf[100];
    fscanf(ptr,"%*s %*s %*s %*s %*s %*s %*s %s ",buf); //skip first line and stuff before first value(column names)
    while (fscanf(ptr,"%*s %*s %*s %*s %s  ",buf)==1) 
    {

        fprintf(fp, "%s\n",buf);
    }
    fclose(fp); 
    return 0; 
} 

Second set of code

#include <stdio.h>
#include <stdlib.h>

int main () {
   FILE *fp;
   char str[100];

   /* opening file for reading */
   fp = fopen("NEWdata.txt" , "r");
   if(fp == NULL) {
      perror("Error opening file");
      return(-1);
   }
   int i;
   while( fgets (str, 100, fp)!=NULL ) {
      /* writing content to stdout */
      sscanf (str,%u,i);
    printf(%u,i);

   }
   fclose(fp);

   return(0);
}

my supposedly command line enter image description here

error im getting is below enter image description here

 if (measure = 10)
            fprintf (ofp, "%f\n", measure - 10);
        else
            fprintf (ofp, "%f\n", measure);
#include <stdio.h>

#define MAXC 1024       /* if you need a constant, #define one (or more) */
#define MAXF   32

int main (int argc, char **argv) {

    char buf[MAXC];     /* buffer to hold each line read from file */
    size_t n = 0;       /* line counter */
   FILE *fp, *ofp;     /* file pointer, output file pointer */

    if (argc < 3 ) {    /* validate 2 arguments given for in/out filenames */
        fprintf (stderr, "error: insufficient input,\n"
                         "usage: %s filename outfilename\n", argv[0]);
        return 1;
    }

    /* open file/validate file open for reading */
    if ((fp = fopen ("Data.txt", "r")) == NULL) {
        perror ("fopen-argv[1]");
        return 1;
    }

    if ((ofp = fopen ("NEWdata.txt", "w")) == NULL) {
        perror ("fopen-argv[2]");
        return 1;
    }

    if (!fgets (buf, MAXC, fp)) {   /* read/discard 1st line */
        fputs ("error: EOF on read of first line.\n", stderr);
        return 1;
    }

    while (fgets (buf, MAXC, fp)) { /* read all remaining lines */
        char date[MAXF], time[MAXF], prod[MAXF], unit[MAXF];
        double measure;

        if (sscanf (buf, "%s %s %s %lf %s", /* validate all 5 fields */
                    date, time, prod, &measure, unit) != 5) {
            fprintf (stderr, "error: invalid format, line: %zu\n", n + 1);
            continue;
        }

        /* do whatever you need with the separated values.
         * if measure is 10.xx, then make measure 0.xx
         */
        if (measure = 10)
            fprintf (ofp, "%f\n", measure - 10);
        else
            fprintf (ofp, "%f\n", measure);

        n++;    /* increment line counter */
    }
}
Serg
  • 3
  • 5
  • Then just read the first line and throw it away. Suggest using `fgets`. – kaylum Nov 28 '19 at 21:00
  • 1
    `char* buf[100];` That's not what you want. Should be `char buf[100];` – kaylum Nov 28 '19 at 21:01
  • I changed it to char but fgets is not working, at this point this code is driving me nuts @kaylum – Serg Nov 29 '19 at 02:59
  • Define "not working". Can't help you unless you show the code and describe the problem more clearly. – kaylum Nov 29 '19 at 03:01
  • @kaylum i am starting to get a hang after looking online to learn, but if i am doing it right, my problem is applying the formula, since fgetc is unsigned char, using fgets didn't work my case – Serg Nov 29 '19 at 03:34
  • `fscanf(ptr,"%*s %*s %*s %*s ",buf); //skip first line(column names)` (How many lines are you skipping? You skip 2) – David C. Rankin Nov 29 '19 at 03:36
  • Why don't you use `fscanf` (of `fgets` followed by `sscanf`) to read the values back as integers instead of `fgetc`? "using fgets didn't work my case" - it should work. If it doesn't it means you have a mistake somewhere. But don't just give up on it because that is the better way to do it. `fgetc` will only cause you more problems. – kaylum Nov 29 '19 at 03:56
  • @DavidRankin-ReinstateMonica I see what you mean but playing around with it, it still skips, how so? – Serg Nov 29 '19 at 03:56
  • @kaylum I been trying and looking online and i can not figure that way out, any guidance is appreciated! "use fscanf (of fgets followed by sscanf) to read the values back as integers instead of fgetc" – Serg Nov 29 '19 at 04:37
  • @Serg post 5-10 lines of your input file and we can help you come up with a way to read it. (also, when you edit your question -- **add** new information below your original question. If you change your original code, then all comments prior to your change no longer make sense...) Additionally, ASCII `10` is the `'\n'` character and `0` is the nul-character. You are in effect writing *nul-characters* to your new file. See [ASCII Table and Description](http://www.asciitable.com/). Is that what you intended? – David C. Rankin Nov 29 '19 at 04:48
  • @DavidRankin-ReinstateMonica i do not how to put int my lines of code without making it not be space inbetween so i put images instead, hope that helps... yes i understand and i have no other changes to make to code and i tried applying previous comments to it, but i won't no more – Serg Nov 29 '19 at 04:59
  • Oh, you just indent your code by 4-spaces (at the beginning of each line) and it will format as code. You can also wrap your code block in `\`\`\`c` (above) and `\`\`\`` (below) and it will format as code as well. (though it is preferred if you just add 4-spaces before each line and you don't have to worry about the language code - to have syntax highlighting work `:)` With your code you can't replace `10` with `0` in a text file. If you do, the functions that read text files will consider the first *nul-character* as the end of file. (and you only get the first line back) – David C. Rankin Nov 29 '19 at 05:01
  • @DavidRankin-ReinstateMonica another user suggested use " fscanf (of fgets followed by sscanf) to read the values back as integers instead of fgetc" if this will fix that then i am stuck on that then – Serg Nov 29 '19 at 05:09
  • Is there any way you can post a few lines of `Data.txt` so I can see what I looks like. That would allow everyone here to identify where you have problems in your code. Yes, using `fgets()` and then `sscanf()` is much less error prone than reading directory with `fscanf`. One mismatched character in a line will cause a *matching-failure* resulting in an endless-loop with `fscanf()` unless you clear to end-of-line before your next read. – David C. Rankin Nov 29 '19 at 05:12
  • yes the post is now more formmated appropriately @DavidRankin-ReinstateMonica – Serg Nov 29 '19 at 05:14
  • Yes, I found the pictures after I reformatted the question. Indenting by 4-space also works with data. Hold on and I'll write a quick example. Are you using VS or MinGW? – David C. Rankin Nov 29 '19 at 05:17
  • I don't know what that is, i am using windows 10, application dev-c++, c based – Serg Nov 29 '19 at 05:18
  • So all you need to get from `Data.txt` is the value of `"Measurement"` to use somewhere else. – David C. Rankin Nov 29 '19 at 05:34
  • @DavidRankin-ReinstateMonica the data.txt file's value of measurement yes, will be used to apply a formula, but all i want to figure out for now is if its value of 10 it will turn 0 and so which is why i used the first code to take out that coloumn and then work on it alone, i thought it would be easier – Serg Nov 29 '19 at 05:45
  • OK, easy enough. How close to `10` is `10`? (`10.0001` -- is that `10`) or do you mean `10.0000` -- floating-point comparisons are inherently non-exact. You can compare within a tolerance (e.g. `1E-6` or so). Your `Data.txt` contains floating-point values (e.g. `1.991`). When you say `10` - do you just mean the integer part of the number? – David C. Rankin Nov 29 '19 at 06:04
  • @DavidRankin-ReinstateMonica for now just 10, as the file goes on " 10 " appears... so yes – Serg Nov 29 '19 at 06:06

1 Answers1

1

If I understand correctly and you want to read the values from Data.txt and, if the value of Measurement is 10, you want to set the value to 0. As noted in my comment, your Measurement values is a floating-point number (double is used below). The comparison of floating point numbers is inherently inexact due to all numbers not being able to be represented exactly in floating-point format. (10.0 can be represented exactly, but be aware of the limitations). See Is floating point math broken? and Why Are Floating Point Numbers Inaccurate?

Before getting there, Avoid Hardcoding Filenames or using Magic-Numbers in your code. main() takes arguments that allow you to pass information to your code. You can simply pass the filename to read as the first argument to your program or take the filename as input. e.g.

#include <stdio.h>

#define MAXC 1024       /* if you need a constant, #define one (or more) */
#define MAXF   32

int main (int argc, char **argv) {

    char buf[MAXC];     /* buffer to hold each line read from file */
    size_t n = 0;       /* line counter */
    FILE *fp;           /* file pointer */

    if (argc < 2 ) {    /* validate 1 argument given for filename */
        fprintf (stderr, "error: insufficient input,\n"
                         "usage: %s filename\n", argv[0]);
        return 1;
    }

    /* open file/validate file open for reading */
    if ((fp = fopen (argv[1], "r")) == NULL) {
        perror ("fopen-argv[1]");
        return 1;
    }

Using fgets() and a buffer (e.g. a character array of MAXC, max characters), you can read and discard your first line. (*don't forget to validate the read):

    if (!fgets (buf, MAXC, fp)) {   /* read/discard 1st line */
        fputs ("error: EOF on read of first line.\n", stderr);
        return 1;
    }

Now simply loop reading each subsequent line with fgets() into the same buffer and then pass that buffer to sscanf() for parsing the values you need from the line, e.g.

    while (fgets (buf, MAXC, fp)) { /* read all remaining lines */
        char date[MAXF], time[MAXF], prod[MAXF], unit[MAXF];
        double measure;

        if (sscanf (buf, "%s %s %s %lf %s", /* validate all 5 fields */
                    date, time, prod, &measure, unit) != 5) {
            fprintf (stderr, "error: invalid format, line: %zu\n", n + 1);
            continue;
        }

(note: if the format of the line is bad, your read does not fail as it would with fscanf(). Here by reading with fgets(), you consume one-line at at time, regardless of format, and then use sscanf() to parse the values from the line. If the line format does not match your format-string, you simply discard the line and go read the next line.)

Now you can do whatever you like with the values separated into date, time, prod, measure & unit. Here we will simply compare measure to see if it is 10.0 or greater up to 11.0 (non-inclusive) and subtract 10.0 from the value making the value 0.xxx where it was 10.xxx. You can simply output 0.0 if you like (up to you)

        /* do whatever you need with the separated values.
         * if measure is 10.xx, then make measure 0.xx
         */
        if (10.0 <= measure && measure < 11.0)
            printf ("measurement[%2zu]: %.3f   (was %.3f)\n",
                    n, measure - 10., measure);
        else
            printf ("measurement[%2zu]: %.3f\n", n, measure);

        n++;    /* increment line counter */
    }
}

That is about as simple an example as you want. The fundamentals of (1) read with fgets() and (2) parse with sscanf() can cover a wide range of input situations. You will use it over and over again. The reason to do so rather than using fscanf() directly is to prevent a format error of a single line causing a matching-failure where character extraction from the input-stream stops leaving the offending characters in the input-stream unread, just waiting to bite you again on your next attempted input.

The full example is:

#include <stdio.h>

#define MAXC 1024       /* if you need a constant, #define one (or more) */
#define MAXF   32

int main (int argc, char **argv) {

    char buf[MAXC];     /* buffer to hold each line read from file */
    size_t n = 0;       /* line counter */
    FILE *fp;           /* file pointer */

    if (argc < 2 ) {    /* validate 1 argument given for filename */
        fprintf (stderr, "error: insufficient input,\n"
                         "usage: %s filename\n", argv[0]);
        return 1;
    }

    /* open file/validate file open for reading */
    if ((fp = fopen (argv[1], "r")) == NULL) {
        perror ("fopen-argv[1]");
        return 1;
    }

    if (!fgets (buf, MAXC, fp)) {   /* read/discard 1st line */
        fputs ("error: EOF on read of first line.\n", stderr);
        return 1;
    }

    while (fgets (buf, MAXC, fp)) { /* read all remaining lines */
        char date[MAXF], time[MAXF], prod[MAXF], unit[MAXF];
        double measure;

        if (sscanf (buf, "%s %s %s %lf %s", /* validate all 5 fields */
                    date, time, prod, &measure, unit) != 5) {
            fprintf (stderr, "error: invalid format, line: %zu\n", n + 1);
            continue;
        }

        /* do whatever you need with the separated values.
         * if measure is 10.xx, then make measure 0.xx
         */
        if (10.0 <= measure && measure < 11.0)
            printf ("measurement[%2zu]: %.3f   (was %.3f)\n",
                    n, measure - 10., measure);
        else
            printf ("measurement[%2zu]: %.3f\n", n, measure);

        n++;    /* increment line counter */
    }
}

Example Input File

$ cat dat/data_timestamp.txt
TimeDateStamp Product Measurement Unit
2019-11-09 16:54    FS2012  0.344   SLPM
2019-11-09 16:54    FS2012  0.344   SLPM
2019-11-09 16:54    FS2012  0.344   SLPM
2019-11-09 16:54    FS2012  0.344   SLPM
2019-11-09 16:54    FS2012  0.136   SLPM
2019-11-09 16:54    FS2012  0.136   SLPM
2019-11-09 16:54    FS2012  0.136   SLPM
2019-11-09 16:54    FS2012  0.136   SLPM
2019-11-09 16:54    FS2012  0.047   SLPM
2019-11-09 16:54    FS2012  0.047   SLPM
2019-11-09 16:54    FS2012  0.047   SLPM
2019-11-09 16:54    FS2012  0.047   SLPM
2019-11-09 16:54    FS2012  1.991   SLPM
2019-11-09 16:54    FS2012  1.991   SLPM
2019-11-09 16:54    FS2012  1.991   SLPM
2019-11-09 16:54    FS2012  10.0    SLPM
2019-11-09 16:54    FS2012  10.661  SLPM
2019-11-09 16:54    FS2012  10.991  SLPM
2019-11-09 16:54    FS2012  11.0    SLPM

Example Use/Output

Below, I show where the 10 was reduced to 0:

$ ./bin/read_data_timestamp dat/data_timestamp.txt
measurement[ 0]: 0.344
measurement[ 1]: 0.344
measurement[ 2]: 0.344
measurement[ 3]: 0.344
measurement[ 4]: 0.136
measurement[ 5]: 0.136
measurement[ 6]: 0.136
measurement[ 7]: 0.136
measurement[ 8]: 0.047
measurement[ 9]: 0.047
measurement[10]: 0.047
measurement[11]: 0.047
measurement[12]: 1.991
measurement[13]: 1.991
measurement[14]: 1.991
measurement[15]: 0.000   (was 10.000)
measurement[16]: 0.661   (was 10.661)
measurement[17]: 0.991   (was 10.991)
measurement[18]: 11.000

Look things over and let me know if this is close to what you need. I may still be misunderstanding what you are trying to achieve with 10 to 0, but just drop a comment below if I misunderstood and I'm happy to help further.

Writing To Output File Taken As 2nd Argument To Program

To write the adjusted Measurement value alone to an output file of your choosing, you can simply provide the output filename you want to use after your input filename on the command line and then open a file for output using argv[2] (your second command-line argument to main()) The changes are minimal. Just add another FILE* pointer ofp (for output file-pointer) and then open that file for writing:

    FILE *fp, *ofp;     /* file pointer, output file pointer */

    if (argc < 3 ) {    /* validate 2 arguments given for in/out filenames */
        fprintf (stderr, "error: insufficient input,\n"
                         "usage: %s filename outfilename\n", argv[0]);
        return 1;
    }

    /* open file/validate file open for reading */
    if ((fp = fopen (argv[1], "r")) == NULL) {
        perror ("fopen-argv[1]");
        return 1;
    }

    if ((ofp = fopen (argv[2], "w")) == NULL) {
        perror ("fopen-argv[2]");
        return 1;
    }

Then just output the adjusted measurement using fprintf, e.g.

        if (10.0 <= measure && measure < 11.0)
            fprintf (ofp, "%.3f\n", measure - 10.);
        else
            fprintf (ofp, "%.3f\n", measure);

(the rest of the program is exactly the same)

#include <stdio.h>

#define MAXC 1024       /* if you need a constant, #define one (or more) */
#define MAXF   32

int main (int argc, char **argv) {

    char buf[MAXC];     /* buffer to hold each line read from file */
    size_t n = 0;       /* line counter */
    FILE *fp, *ofp;     /* file pointer, output file pointer */

    if (argc < 3 ) {    /* validate 2 arguments given for in/out filenames */
        fprintf (stderr, "error: insufficient input,\n"
                         "usage: %s filename outfilename\n", argv[0]);
        return 1;
    }

    /* open file/validate file open for reading */
    if ((fp = fopen (argv[1], "r")) == NULL) {
        perror ("fopen-argv[1]");
        return 1;
    }

    if ((ofp = fopen (argv[2], "w")) == NULL) {
        perror ("fopen-argv[2]");
        return 1;
    }

    if (!fgets (buf, MAXC, fp)) {   /* read/discard 1st line */
        fputs ("error: EOF on read of first line.\n", stderr);
        return 1;
    }

    while (fgets (buf, MAXC, fp)) { /* read all remaining lines */
        char date[MAXF], time[MAXF], prod[MAXF], unit[MAXF];
        double measure;

        if (sscanf (buf, "%s %s %s %lf %s", /* validate all 5 fields */
                    date, time, prod, &measure, unit) != 5) {
            fprintf (stderr, "error: invalid format, line: %zu\n", n + 1);
            continue;
        }

        /* do whatever you need with the separated values.
         * if measure is 10.xx, then make measure 0.xx
         */
        if (10.0 <= measure && measure < 11.0)
            fprintf (ofp, "%.3f\n", measure - 10.);
        else
            fprintf (ofp, "%.3f\n", measure);

        n++;    /* increment line counter */
    }
}

If I then call my program with two-arguments (e.g. the input and output filenames) as follows:

$ ./bin/read_data_timestamp2 dat/data_timestamp.txt dat/measure_val.txt

I would read from my input file dat/data_timestamp.txt and write the results to my output file dat/measure_val.txt (you can use any filename you like for your output file, but your input would be Data.txt).

Resulting OUtput File

$ cat dat/measure_val.txt
0.344
0.344
0.344
0.344
0.136
0.136
0.136
0.136
0.047
0.047
0.047
0.047
1.991
1.991
1.991
0.000
0.661
0.991
11.000

Let me know if that clears it up.

David C. Rankin
  • 81,885
  • 6
  • 58
  • 85
  • This is by the looks of its what i was looking for, but at a glance i do not understand using file, so if i were to use my file where would it go... as for the rest i understand but will go more in depth tomorrow since its so late here, i will get back to you on the rest tomorrow thank you in advance... i just wonder how to use my own file, as these files can differ so i want to know where to change it so the input is accordinly – Serg Nov 29 '19 at 06:44
  • If you simply want to output the `Measurement` values alone to a new file, you can simply output the values (removing the `measurement[%2zu]` and redirect the output to a new file, (e.g. `./bin/read_data_timestamp dat/data_timestamp.txt > newfile_measurement.txt`). Or, you can pass the output filename as the 2nd argument and open a file for writing (e.g `FILE *ofp;`) and then `ofp = fopen (argv[2], "w");` (don't forget to ***validate*** it is actually open) then write to the file with `fprintf (ofp, "%.3f\n", measure);` (or `measure - 10.0`). – David C. Rankin Nov 29 '19 at 06:49
  • yes ok i understand that, but i dont understand where your input file is coming into the program as your file is called "$ cat dat/data_timestamp.txt" and yet i do not see it, is what confuses me – Serg Nov 29 '19 at 06:53
  • Oh -- remember the *Avoid Hardcoding Filenames* advice. My input filename is `dat/data_timestamp.txt` that I provide on the command line. (e.g. `./prog filename`). There `argv[1]` is the first comman-line argument (`argv[2]`, the second, and so on) So if you want a new file using redirection, you would do `./prog filename > outfilename`. I'll drop an example taking both filenames on the command line and you can compare. – David C. Rankin Nov 29 '19 at 06:57
  • Take a look and let me know if that clears things up. The filenames (both input and output) are just passed on the command line as your two arguments. In Dev-C++, you will have a dialog that allows you to specify your program arguments in one of your project settings. I just compile and run everything from the command-line anyway -- much faster, less worrying about finding the setting in your IDE. I don't have Dev-C++, but most IDEs provided a command line argument dialog in your project options. – David C. Rankin Nov 29 '19 at 07:13
  • still do not understand where in the code you used so it opens those files, like you did not use the words of the file at all anywhere, how does the code know what file name to be opening... and "$ ./bin/read_data_timestamp2 dat/data_timestamp.txt dat/measure_val.txt" this i do not get, is this suppose to be some kind of cmd command to put in ....just read your comment I'll look into it right now – Serg Nov 29 '19 at 07:16
  • You see `int main (int argc, char **argv)`. The `int argc` is the *argument count* that tells you how many arguments are provided on the command line. `char **argv` this an array of pointers to the arguments themselves. Where you see `argv[1]` that is just the array that contains my input filename `dat/data_timestamp.txt` that I provide right after the program on the command line. In the update where you see `argv[2]` that is just the array containing my output filename `dat/measure_val.txt`. When using an IDE, you have the ability to specify the arguments in one of your settings. – David C. Rankin Nov 29 '19 at 07:21
  • If you want to ignore the hardcoding filenames rule, you can just replace `argv[1]` with `"Data.txt"` and `argv[2]` with your output filename until you figure out where the settings for the command line arguments are in Dev-C++ (which is why I hate IDEs for programmers learning a language. Hunting down where the IDE hides things is a pain). Since you use MinGW, you can just add the path to `..\MinGW\bin` to your environment path and compile using the Windows Command Prompt (or PowerShell). Much faster than setting up a project for each program `:)` – David C. Rankin Nov 29 '19 at 07:25
  • You would of course get rid of the `if (argc < 3 ) {...` check if you hardcode the filenames.. – David C. Rankin Nov 29 '19 at 07:28
  • i added the error and what i am putting in the settings on the post – Serg Nov 29 '19 at 07:32
  • i tried the other way, and nothing changes actually – Serg Nov 29 '19 at 07:35
  • Oh No, No, No... You put filenames where compiler-options go.... That dialog is for additional parameters (options) to send to `gcc` when compiling. (sigh) This is the problem with IDEs. I've been searching for DevC++ documentation -- and it is non-existent, or I'd send you a link. – David C. Rankin Nov 29 '19 at 07:40
  • going about the way of replacing argv[1] with "Data.txt" and argv[2] with my output filename is not working either, no changes were made it only took the values and listed them alone – Serg Nov 29 '19 at 07:43
  • Here is a decent link on how to [set the PATH in Win10](https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/). Find where `MinGW` is installed (probably under `Program Files x86\DevC++\MinGW` (or something similar). Add the path to the `...\MinGW\bin` directory, then open the Command Prompt and change to where your C program is. Compile with `gcc -Wall -Wextra -pedantic -o name.exe source.c`. Then just run the program `name.exe path\to\Data.txt path\to\outfile.txt`. You don't have a C problem, you have a "How do I configure DevC++ problem?" (sigh). – David C. Rankin Nov 29 '19 at 07:45
  • Listing them alone?? Did you change to use `fprintf (ofp, "%.3f\n", measure);` as the output commands? – David C. Rankin Nov 29 '19 at 07:46
  • I will try that tomrrow because i have to get up soon, for now using the hardcode file names, it is listing as it is for your measure_val.txt in the updated example but it is not changing the 10 to 0..... i added the measure conversion code in my post – Serg Nov 29 '19 at 07:50
  • Here, I'll post the full code for the 2nd version. Hardcode both filenames. The only issue is you forgot to change the output from `printf (....` to `fprintf (ofp, ...`. Don't forget to remove the `if (argc < 3 ) { ... }` block as well. Good luck with your code. Drop a comment tomorrow if you are still stuck. – David C. Rankin Nov 29 '19 at 07:59
  • i posted what i got, based off your example... thank you for your assistance thus far – Serg Nov 29 '19 at 08:04
  • `if (measure = 10)` ... Umm... `if (measure == 10)` (you don't want to assign `measure = 10` you want to compare `measure == 10`). We will talk about compiling with full-warnings enable another time `:)` **Remove** the `if (argc < 3 ) { ... }` code when you hardcode the filenames -- you don't have any command line arguments so `argc` will always be `< 3`. Just delete that block of code. – David C. Rankin Nov 29 '19 at 08:08