I have an array and am able to print the portion of it that I want. But what I would like to do is write that portion to a new array. Does anyone know how to do this?
Thanks in advance!
char line[128];
char *line1;
char *pch,*pch1;
char key[]="REMARK 290 ";
char key1[]="X";
int start=24;
int len=35;
while (fgets(line,sizeof line, file)!=NULL)
{
pch=strstr(line,key);
pch1=strstr(line,key1);
if(pch!=NULL && pch1!=NULL){
printf("%.*s\n",len,line+start);
What gets printed at the end is what I want piped into a new array.
Pipes are used to communicate between processes. You can’t pipe from one array to another.
If the
printf()at the end of your code does what you want, then you simply want to usesprintf()to put the result of the “print” in an array instead of sending it tostdout.