All pastes #1046237 Raw Edit

Mine

public c v1 · immutable
#1046237 ·published 2008-06-12 18:01 UTC
rendered paste body
#include <stdio.h>#include <string.h>int main(void){    FILE *file;    char txt_file[256]; //location    char text[100];  //text to read from file    /***************askforfile()***************/    int askforfile() ///File location procedure.{       printf("\nFile?: ");    scanf("%s",txt_file);     if(!strstr(txt_file,".txt"))    {      printf("Please enter a .txt file.\n");     askforfile();     }}/***************askforfile()***************/for(;;) //main loop.  main job.{        askforfile();        file = fopen(txt_file, "r");        if ( file == NULL)         {              printf("Error in locating file.\n");              askforfile();         }           while(fgets(text, 100, file) != NULL )        {         printf("Contents: %s",text);           }   }   system("pause");    fclose(file);   return 0; }