I'm starting in C and I'm currently studying on pipes . I copied an example from the book to see how it works and then try it on its own, but it did not occur what was supposed to happen.
Code 1:
#include <stdio.h>
int main()
{
float latitude;
float longitude;
char info[80];
int started=0;
puts("data=[");
while (scanf("%f,%f,%79[^\n]",&latitude,&longitude,info)==3){
if (started)
printf(",\n");
else
started=1;
printf("{latitude: %f, longitude: %f, info: '%s'}",latitude,longitude,info);
}
puts("\n]");
}
Code 2:
#include <stdio.h>
int main()
{
float latitude;
float longitude;
char info[80];
while (scanf("%f,%f,&79[^\n]",&latitude,&longitude,info)==3)
if((latitude> 26)&&(latitude< 34))
if ((longitude> -76)&&(longitude< -64))
printf("%f,%f,%s\n",latitude,longitude,info);
}
And in the text file ( qualquertexto.txt
):
28.432423,-74.234231,bermudas
CMD :
(codigo2 | codigo1) < qualquertexto.txt > saida.txt
But only data=[
appears
And it was to appear what was in the text file, after all, obey all conditions. What did I miss?