Home Forums C Programming Read 1st col vals of i/pfile;create o/p fl for each diff val

Viewing 2 reply threads
  • Author
    Posts
    • #2225
      GarnetHuynh
      Participant

      Hi,

      The following C code, at present does the following :-

      Takes the Output file name from character 1 of the input filename (ALLSMFAS.ref) and creates a new file (A.brt) as follows :-

      ALLSMFAS.ref


      AD,B,0424,0415,89375,,A,2,,80,,
      AD,B,0424,0417,89375,,A,1,,82,,
      AD,B,0416,0410,89375,,B,2,,-7,2,
      BN,B,0135,0094,65625,,D,,,0,1,H
      BN,B,0338,0337,65824,,B,,,-18,1,
      BN,B,0334,0339,65824,,C,,,65,,
      CA,T,,SREC,47221,,C,,R,0,,
      CA,T,,X171,47221,,A,6,,60,,
      CA,T,,X173,47221,,A,5,,60,,
      CC,B,1783,1574,48231,,C,1,,60,,
      CC,B,1783,1576,48231,,C,2,,60,,
      CC,B,1783,1578,48231,,C,3,,60,,

      A.brt


      B0424041589375 B0424041789375 B0416041089375 B0135009465625 B0338033765824 B0334033965824
      T SREC47221 T X17147221 T X17347221 B1783157448231 B1783157648231 B1783157848231

      But now,I want to modify the above program to read each value of column 1 of my input file (ALLSMFAS.ref) and create Output file with name as the value at the column 1 of the input file. For each change in the value at column 1 of input file, a new output file should be created, as follows :-

      ALLSMFAS.ref


      AD,B,0424,0415,89375,,A,2,,80,,
      AD,B,0424,0417,89375,,A,1,,82,,
      AD,B,0416,0410,89375,,B,2,,-7,2,
      BN,B,0135,0094,65625,,D,,,0,1,H
      BN,B,0338,0337,65824,,B,,,-18,1,
      BN,B,0334,0339,65824,,C,,,65,,
      CA,T,,SREC,47221,,C,,R,0,,
      CA,T,,X171,47221,,A,6,,60,,
      CA,T,,X173,47221,,A,5,,60,,
      CC,B,1783,1574,48231,,C,1,,60,,
      CC,B,1783,1576,48231,,C,2,,60,,
      CC,B,1783,1578,48231,,C,3,,60,,
      :
      :
      and so on..

      the following are the output files.

      AD.brt


      B0424041589375 B0424041789375 B0416041089375

      BN.brt


      B0135009465625 B0338033765824 B0334033965824

      CA.brt


      T SREC47221 T X17147221 T X17347221

      CC.brt


      B1783157448231 B1783157648231 B1783157848231

      and so on ….

      The logic for taking the output filename name from character 1 of the input filename is as below :-

      I think I have to change at this place so that the code reads each value of column 1 of my input file (ALLSMFAS.ref) and
      create Output file with name as the value at the column 1 of the input file. For each change in the value at column 1 of
      input file, a new output file is created. I am unable to proceed further to implement this.

      Request you, if you could please help me on this.

      Thanks a lot.
      Marconi.

    • #3606
      GWILouisaxwzkla
      Participant

      Heres some code that does what you want ( maybe you can splice this into your program ):

    • #3607
      GarnetHuynh
      Participant

      I had modified my program with the following code to read each value of column 1 of my input file (*.ref) and create multiple Output files (*.brt) with name as the value at the column 1 of the input file. For each change in the value at column 1 of input file, a new output file (*.brt) should be created. But it doesn’t seem to do what is required and when I run the application it gets hung. Could you please help me with the changes to the following code so that it works :-

      Thanks a lot,
      Marconi.

Viewing 2 reply threads
  • The forum ‘C Programming’ is closed to new topics and replies.