Witam, mam napisać prosty projekt z wykorzystaniem modułów, choć nie zbyt to ogarniam i nigdzie nie mogłem znaleźć jak rozwiązać ten problem, mianowicie przy kompilacji wyskakują mi błędy: " [Linker error] undefined reference to `Otworz' " oraz te same do pozostałych funkcji. Co mi brakuje w tych kodach? Z góry wielkie dzięki za pomoc.
main.c
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<process.h>
#include "funkcje.h"
int i,j,ec,fg,ec2;
char fn[20],e,c;
FILE *fp1,*fp2,*fp;
int main()
{
do
{
printf("\n\t\t----------------- Edytor tekstowy -----------------");
printf("\n\n\n\tOpcje:\n ");
printf("\n\t1.Nowy plik\n\t2.Otworz\n\t3.Dodaj\n\t4.Usun\n\t5.Wyjscie\n");
printf("\n\tKomenda: ");
scanf("%d",&ec);
switch(ec)
{
case 1:
Nowy();
break;
case 2:
Otworz();
break;
case 3:
Dodaj();
break;
case 4:
Usun();
break;
case 5:
exit(0);
}
}while(1);
system("cls");
}
funkcje.h
#ifndef FUNKCJE_H
#define FUNKCJE_H
void Nowy();
void Otworz();
void Dodaj();
void Usun();
#endif
funkcje.c
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<process.h>
#include "funkcje.h"
void Nowy()
{
fp1=fopen("temp.txt","w");
printf("\n\tEnter the text and press '.' to save\n\n\t");
while(1)
{
c=getchar();
fputc(c,fp1);
if(c == '.')
{
fclose(fp1);
printf("\n\tEnter then new filename: ");
scanf("%s",fn);
fp1=fopen("temp.txt","r");
fp2=fopen(fn,"w");
while(!feof(fp1))
{
c=getc(fp1);
putc(c,fp2);
}
fclose(fp2);
break;
}
}
}
void Otworz()
{
printf("\n\tEnter the file name: ");
scanf("%s",fn);
fp1=fopen(fn,"r");
if(fp1==NULL)
{
printf("\n\tFile not found!");
goto end1;
}
while(!feof(fp1))
{
c=getc(fp1);
printf("%c",c);
}
end1:
fclose(fp1);
printf("\n\n\tPress any key to continue...");
getch();
}
void Usun()
{
printf("\n\tEnter the file name: ");
scanf("%s",fn);
fp1=fopen(fn,"r");
if(fp1==NULL)
{
printf("\n\tFile not found!");
goto end2;
}
fclose(fp1);
if(remove(fn)==0)
{
printf("\n\n\tPlik zostal usuniety pomyslnie!");
goto end2;
}
else
printf("\n\tError!\n");
end2: printf("\n\n\tPress any key to continue...");
getch();
}
void Dodaj()
{
printf("\n\tEnter the file name: ");
scanf("%s",fn);
fp1=fopen(fn,"r");
if(fp1==NULL)
{
printf("\n\tFile not found!");
goto end3;
}
while(!feof(fp1))
{
c=getc(fp1);
printf("%c",c);
}
fclose(fp1);
printf("\n\tType the text and press 'Ctrl+S' to append.\n");
fp1=fopen(fn,"a");
while(1)
{
c=getch();
if(c==19)
goto end3;
if(c==13)
{
c='\n';
printf("\n\t");
fputc(c,fp1);
}
else
{
printf("%c",c);
fputc(c,fp1);
}
}
end3: fclose(fp1);
getch();
}