title: How to read file from the command line
body: <p>I'm starting out learning C and I'm supposed to read in a txt file that I have and I am attempting to open it from the command line. I am supposed to take the data from the txt file and decode it, but for now I'm just attempting to write it to a new file and can't seem to get my input file to read in and subsequently write to the new txt file I want to create. I've tried using a while loop to print out the contents of the file but to no avail. 
  Any help would be appreciated. </p>
  
  <p>Edit:
  My program currently does not print anything out through my while loop and gives me a "segmentation fault" error and does not write to my new txt file, although it creates it, nothing is stored in the file. 
  The contents of the file are long, but follows this pattern:</p>
  
  <pre><code>encodedLength,bits,base64
  
  12,64,AAAAAAAAAEA=
  12,64,vvj7ZlmphkA=
  12,64,k+Oj/7LbkUA=
  56024,64,qZzGabZBf0CQT8vJMEJ/QISgOVMaRH9AwB2+bG9Lf0BpLEli0FF/QKEpqrloU39A9klOPONTf0CETlNyiV9/QKUKUN66Yn9A7CEjAnlsf0ATW5MDlnF/QG1IilrIdH9AhU5hRvF0f0DHblZlf3t/QLHq2kXRe39AF951+tqCf0C7/5Gv+YN/QD6plms3in9AWwvIRy2Lf0BY5BOuJJR/QDOqDBoxm39AnD3CrKOxf0DOKmoimrJ/QGh1pV4Vs39AGRJSh2ezf0CZnRzF4rN/QJ2y6tkLtH9Aj2XT7jS0f0ButtYDXrR/QDql9BiHtH9A8TEtLrC0f0AqJe5YArV/QGJZu24SvH9ArdxKi3XDf0BTUi3Jx8N/QLmkMUZsxH9ARgiIpwLLf0DsSAGSWc9/QBxGuUw1039ALnyq8dnTf0APkUWYftR/QBnhLsKn1H9AQZAiU07ef0D2a2fCneN/QBSk4Cnw439ACS3FXRnkf0DqU8SRQuR/QLgY3sVr5H9AdHsS+pTkf0AcfGEuvuR/QJS+/yPN539AoG68zonqf0B/kCovZ+5/QKcy0WmQ7n9AvXKSpLnuf0C8UG7f4u5/QKzMZBoM739AiOZ1VTXvf0BSnqGQXu9/QAn058uH739AredIB7Hvf0BAeKEIbvJ/QJCG4UWX8n9AzTI8g8Dyf0D3fLHA6fJ/QAtlQf4S839AD+vrOzzzf0ABD7F5ZfN/QN/QkLeO839AqzCL9bfzf0BkLqAz4fN/QArKz3EK9H9AnQMasDP0f0Aa237uXPR/QIdQ/iyG9H9A4WOYa6/0f0ApFU2q2PR/QF1kHOkB9X9Acsxj5ab1f0AtRjtpjfh/QMP3qG4y+X9A+u5GsFv5f0AdhP/xhPl/QC630jOu+X9ALIjAddf5f0AU98i3APp/QOwD7Pkp+n9Axo7rGoT+f0BB0h6l1v5/QHGNvC8p/39A7FczdVL
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>int main(int argc, char* argv[])
      {
          char fileString[256];
          char line[256];
  
          /*Pseudocode
          Need to convert base 64 string back into 32 bit floats
  
          Algorithm:
          Open up file in command line
           Skip first line of txt file
           Read file in line by line
           Convert each line from base64 to 32 bit floats (truncated to 3 decimal places), end each with a new line
           Store all of this in an output file called p1_output.txt
  
           */
  
          printf("Please enter your file name (include file extension): ");
          scanf("%s", &amp;fileString);
          printf("%s\n", fileString);
  
          FILE *inputFile = fopen(fileString, "r");
          FILE *outputFile = fopen("p1_output.txt", "w+");
  
          while(fgets(line, 256, inputFile))
          {
              printf("%s", line);
              fputs(line, outputFile);
  
          }
  
          return 0;
      }
  </code></pre>