come da titolo non riesco ad utilizzare questi file assieme...credo (sottolineo credo perchè potrebbe essere una supidata galattica (sono un niubbo di C..)) si un problema di link..
i file sono:
main.c
/*
* more
* main subroutine - copy input to output
*/
#include <stdio.h>
int main()
{
int ch, colcnt, rowcnt;
colcnt = 1;
rowcnt = 1;
while ( (ch = getchar()) != EOF )
{
putchar(ch);
if ( more(ch, &colcnt, &rowcnt) == 0 )
{
break;
}
}
exit(0);
}
more.c
/*
* more
* more subroutine - controls command prompting
* base on screen size
*/
#include "defs.h"
int more(char ch, int *colcnt, int *rowcnt) {
int Value; /* returned by this function */
if ( ch == '\n' || *colcnt >= LINESIZE )
{
*colcnt = 1;
(*rowcnt)++;
} else
{
(*colcnt)++;
}
if ( *rowcnt == SCRNSIZE )
{
Value = command(rowcnt);
} else
{
Value = 1;
}
return(Value);
}
command.c
/*
* more
* command subroutine - prompts for command
*/
#include <stdio.h>
#include "defs.h"
int command(int *rowcnt)
{
static FILE *fp = NULL;
int Ch, Value;
if ( fp == NULL )
{
fp = fopen("/dev/tty", "r");
}
printf("more?");
fflush(stdout);
if ( (Ch = getc(fp)) == ONELINE )
{
*rowcnt = SCRNSIZE - 1;
Value = 1;
} else if ( Ch == ONESCREEN )
{
*rowcnt = 0;
Value = 1;
} else
{
Value = 0;
}
while ( Ch != EOF && Ch != '\n' )
{
Ch = getc(fp);
}
return(Value);
}
defs.h
/*
* more
* definitions
*/
#define SCRNSIZE 23
#define LINESIZE 80
#define ONELINE '\n'
#define ONESCREEN ' '
makefile
#
# makefile per costruire il file eseguibile More
#
# Seguono le definizioni di alcune macro
#
CC = gcc
SRC = main.c more.c command.c
DEF = defs.h
OBJ = $(SRC:.c=.o)
# La macro $@ prende il nome del target corrente More
More: $(OBJ)
$(CC) $(OBJ) -o $@
.c.o:
$(CC) -c $<
# Si puo' utilizzare anche la dipendenza implicita dei target,
# dettata dal suffisso .c, cosicche' e' sufficiente scrivere
# solamente le regole dove compare la dipendenza esplicita da
# "defs.h"
more.o: $(DEF)
command.o: $(DEF)
clean:
/bin/rm -f $(OBJ) More *~
teoricamente lanciando il comando make dovrebbe crearsi l'eseguibile..
ma non mi succede...
mi ritovo pieno di error e warning.. sapreste aiutarmi??grazie!!