ile önceki without if ’içermiyorsa, hızın ekran indeksine yazdırmak istiyorum. Kodun yazıcısı değilim.hatası: ‘else’ fprintf
Kod burada http://pastebin.com/47CbB1vb
Ve ben sadece fprintf line.Without dahil ettik
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
^
gcc ile derlemeye çalıştığınızda hat almak da derleme
#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 */
için gerekli olduğunu satır kodu derleyebilir ve mükemmel çalışır. Ne değiştirmeliyim?
Kod parçacığınızda 'fprintf' nerede? (205 numaralı hat üzerindeymiş ve 'else' satır 206'da. Kodunuzda o kadar çok satır yok.) –
Olası nedenlerden biri: [Neden bir önceki hata olmadan 'hata' yazan bir derleme hatası alıyorum? '?] ise (http://stackoverflow.com/questions/17587875/why-do-i-get-a-compiling-error-that-says-error-else-without-a-previous-if) – owacoder
@MOehm - Macun linkinde. Ancak sorun, bundan sonra “if” ile bir “if” den sonra sadece iki ifadedir. Hiçbir şey bir çift küme parantezi düzeltmez. – owacoder