I want to print on the screen index of velocity.I am not author of the code.
Code is here http://pastebin.com/47CbB1vb
And get line is also necessary for compilation
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
* get_line:
* Reads a line into string, returns length.
* Kernighan & Ritchie p.69
*
*/
int
get_line(fp, line, lim)
FILE *fp;
char *line;
int lim;
{
int c, i;
i = 0;
while (--lim > 0 && (c = getc(fp)) != EOF && c != '\n')
line[i++] = c;
if (c == '\n')
{
line[i++] = c;
}
line[i] = '\0';
if (c == EOF)
return (-1);
else
return (i);
}
/*
* ignore_line:
* Gets the next line (up to and including the newline
* character) from the file pointed to by fptr and
* promptly loses it. Taken from asc2ah.c.
*
* Siggi 29.06.1990
*/
int
ignore_line(dat_fp)
FILE *dat_fp;
{
char string[256];
char *fgets();
if (fgets(string, 250, dat_fp) == NULL) /* nothing there */
return (-1);
return (0); /* there was something */
WHen I try to compile with gcc
gcc gi_line.c vel2d.c -lm -o vel2d
vel2d.c: In function ‘main’:
vel2d.c:205:19: warning: format ‘%f’ expects argument of type ‘double’, but argument 3 has type ‘int’ [-Wformat=]
fprintf(stdout,"%.1f",index);
^
vel2d.c:206:9: error: ‘else’ without a previous ‘if’
else
^
I have included only fprintf line.Without that line I c can compile code and it works perfectly.So what should I change?