Dear Pete
I have posted one script to insert field saperator into fixed length
fields text file. I feel the following version is better than the
previous.
Vijay
-------------------------------------------------------------------
#include <stdio.h>
#define FNM 5 /* number of fields */
#define F1 4 /* length of the first field */
#define FS "|" /* field saperator */
main()
{
int c,i,len,count;
int flen[FNM-2];
flen[0]=45; /*length of second field */
flen[1]=40; /* length of third field */
flen[2]=40; /* length of last field not reqd */
count=0;
i=0;
len=F1;
c=getchar();
while (c != EOF){
putchar(c);
count=count+1;
c=getchar();
if (count==len){
printf("%s",FS);
len=len+flen[i];
i=i+1;
}
if (c=='\n'){
count=0;
i=0;
len=F1;
putchar(c);
c=getchar();
}
}
}
-----------------------------------------------------------------------------#include <stdio.h>
#define FNM 5 /* number of fields */
#define F1 4 /* length of the first field */
#define FS "|" /* field saperator */
main()
{
int c,i,len,count;
int flen[FNM-2];
flen[0]=45; /*length of second field */
flen[1]=40; /* length of third field */
flen[2]=40; /* length of FNM-1 field ; length of last field not reqd */
count=0;
i=0;
len=F1;
c=getchar();
while (c != EOF){
putchar(c);
count=count+1;
c=getchar();
if (count==len){
printf("%s",FS);
len=len+flen[i];
i=i+1;
}
if (c=='\n'){
count=0;
i=0;
len=F1;
putchar(c);
c=getchar();
}
}
}