struct, funktionen, header files leichte frage



  • Hallo,

    ich habe folgendes gemacht.

    Habe eine Datei namesns

    WordProcessor.h

    _____________________________

    //apo8hkeuh to mege8os tou pinaka
    typedef struct TFS //gia Text File Size
    {
    	int LetterSize;
    	int LineSize;
    };
    
    typedef struct SFTF //gia struct for Text File
    {
    	TFS VSize; //int Size;
    	Type String[MaxLine][MaxLetter];
    };
    
    void Create(SFTF *Word);
    
    Type Anakthsh(SFTF CopyWord, int Line, int Letter);
    
    void Prosartisi(SFTF *Word, Type Letter);
    
    void Diagrafi(SFTF *Word);
    
    int GetLine(SFTF CopyWord);
    
    int GetLetter(SFTF CopyWord);
    
    void Antigrafh(SFTF CopyWord, int Position, int n, SFTF *NewWord);
    
    void Fousion(SFTF *pWord1, SFTF Word2);
    
    int LSeek(SFTF Word, SFTF SeekWord, int *i, int *j);
    

    und die selbe datei in c ist unwichtich.

    Nun ich bekomme in mein programm 1000 fehler in der deklaration wiso?. Muster ich die struckt in WordProcessor.c verschieben oder warum?



  • Erstens solltest du bei einem Typedef einen Zweiten Namen mit angeben:

    typedef struct _TFS //gia Text File Size 
    { 
        int LetterSize; 
        int LineSize; 
    }TFS; 
    
    typedef struct _SFTF //gia struct for Text File 
    { 
        TFS VSize; //int Size; 
        Type String[MaxLine][MaxLetter]; 
    }SFTF;
    

    Und Zweitens woher kommt "Type" ?

    MfG



  • Ah es funktionier alle fehler in header sind wech jetzt bleiben nur fehler in main und in ..c, warum? Uberahl wo SFTF steht kommen fehler!!!

    main.c

    #include <stdio.h>			//Standard input output
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //Skopos ths WortProcesor1.h einai na exoume mia entelos aneksartith	//
    //ylopoihsh kai apokripsis hlopoihseis etsi apoafasisa na ulopoihso thn //
    //sunarthsh se allo arxeio.												//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    #include "WordProcessor1.h"
    
    //Dhlosh sunarthsewn
    //Telos, dhlosh sunarthsewn
    
    void InsertMode(SFTF *Word);
    void CommandMode(SFTF *Word);
    
    /***********************************************************************
    ****************************Kurio Programma*****************************
    ***********************************************************************/
    
    //Shmeiosh : Domhmenos programatismos apokripsi....
    
    int main(void)
    {
    	//Dhlosh Metablhton
    	SFTF Word;
    //Arxikopoihsh
    	Create(Word);
    
    		//Kuria sunarthsh
    
    	InsertMode(&Word);
    	CommandMode(&Word);
    	return 0;
    }
    
    /*
    **************************************************************************
    *																		 *
    *					    Ylopoihsh Sunarthseis							 *
    *																		 *
    **************************************************************************
    */
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	Graffis ena keimeno kai apofhkeuete sto ATD, telos		//
    //				Isodo dedomenon me to idiko xaraktira EOF.				//
    //																		//
    //	Eisodos	:	Ton ATD.												//
    //																		//
    //	Exodos	:	Ton ATD.												//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    void InsertMode(SFTF *Word)
    {
    	//Dhlosh Metablhton
    	Type Charakter;
    //
    	//Den exei nohma arxikopoihsh
    
    		//Kuria Sunarthsh
    	printf("Blhktrologise EOF gia Command mode (kai oxi '\n').\n");
    	scanf("%c",&Charakter);
    	while(Charakter != EOF)
    	{
    		Prosartisi(Word,Charakter);
    		scanf("%c",&Charakter);
    	}
    }
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	Kani diafores allages sto keimeno, epilegonta		    //
    //				pliktrologontas diafora koumbia.						//
    //																		//
    //	Eisodos	:	ATD.													//
    //																		//
    //	Exodos	:	ATD.													//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    void CommandMode(SFTF *Word)
    {
    	//Dhlosh Metablhton
    	char Question;
    	SFTF HelpWord;
    	int Start;
    	int End;
    	int Correctness;
    //
    	Create(*HelpWord);
    	Question=0;
    	Start=0;
    	End=0;
    	Correctness=0;
    
    		//Kurio Programma
    
    	//Epanlipsei eksodos me xaraktira EOF
    	do{
    
    		//Ektiposh ton dia8eshmon epilogon
    		printf("\n\n===============Command Mode==================\n\n");
    		printf("Pliktologise:\n\t(A)   Pros8esh 1 seiras sto keimeno\n");
    		printf("\t(D)   Diagraafi enos plh8os grammon\n");
    		printf("\t(P)   Tuponh n grammes apo to keimeno\n");
    		printf("\t(I)   ???\n");
    		printf("\t(R)   Antikatastash mias sumbolosiras me mia allh\n");
    		printf("\t(L)   Ektiposh ari8mon grammis kai to periexomeno os telos\n");
    		printf("\t(EOF) gi aexodos.\n");
    		printf("=========>");
    
    		//Eisodos epi8hmiths energias
    		scanf("%c",&Question);
    
    		//Ektelesh epi8imhths energias
    		switch(Question)
    		{
    		case A:
    			{
    				printf("Dose to keimeno pou 8eeleis na pros8eshs.\n");
    				InsertMode(&HelpWord);
    				printf("Plhktrologise se pia seira 8eleis na prste8h.\n");
    				printf("==========>");
    				scanf("%d",&Start);
    				Eisagogh(Word,HelpWord,Start);
    				Create(HelpWord);
    				Start=0;
    				break;
    			}
    		case D:
    			{
    				//Diagrafh ena plh8os grammon
    
    				//Eisagogh dedomenon
    				printf("Plhktrologise apo pia grammh na arxish h diagrafi.\n");
    				printf("========>");
    				scanf("%d",&Start);
    				printf("Os pou na diagrafh?.\n");
    				printf("=======>");
    				scanf("%d",&End);
    				//Ektelesh diagrafis
    				LineDelete(Word,Start,End);
    				//reset
    				Start=0;
    				End=0;
    				break;
    			}
    		case P:
    			{
    				//Ebresh apo pou na arxish ektiposh
    				printf("Plhktrologise ton ari8mo ths seira pou 8eleis na ektipo8h.\n");
    				printf("========>");
    				scanf("%d",&Start);
    				//Ebresh os pou na ektipo8h
    				printf("\nPlhktrologise os pia seira 8eleis na ektipo8h\n");
    				printf("========>");
    				scanf("%d",&End);
    				//Ektelesh ths ektipohs
    				MPrint(*Word,Start,End);
    				//reset
    				Start=0;
    				End=0;
    				break;
    			}
    		case I:
    			{
    				//Eisagogh mias sumboloseiras sthn 8esh n
    				printf("Pliktrologis EOF gia eksodos(oxi \n");
    				InsertMode(&localWord);
    				printf("Plhktrologise se pia grammh na eisaxth to kemeno\n");
    				printf("=========>");
    				//Eisodos dedomenon apo pia grammh
    				scanf("%d",&Start);
    				//Eisagogh dedomeno
    				Eisagogh(Word,LocalWord,Start);
    				Create(LocalWord);
    				break;
    			}
    		case R:
    			{
    				//isodos tou ATD gia ebresh
    				printf("Pliktologise to keimeno gia to opoia na kani ereuna");
    				printf("to programm(Eof gia ESCAPE kai oxi \n");
    				InsertMode(&SeekWord);
    				Antikatastash(Word,SeekWord);
    				//reset metablhton
    				Create(TempWord);
    				break;
    			}
    		case L:
    			{
    				//Ektiposh Grammeis
    				printf("Ari8mos grammis einai %d.\n", GetLine(*Word) );
    				//Ebresh grammeis gia ektiposh
    				printf("Plhktrologise ton ari8mo grammhs pou 8eleis na ektipo8h.\n");
    				printf("========>");
    				scanf("%d",&Start);
    				//Sunarthsh gia ektiposh os telos
    				MPrint(*Word,Start,GetLine(*Word));
    				//reset 
    				Start=0;
    				break;
    			}
    		case EOF:	//Exit, bgeni apo thn epanalipsh.
    			}
    				break;
    			}
    		default:
    			{
    				printf("la8os epilogi ksanaprospa8a\n");
    			}
    		}
    	}while(Question != EOF);
    }
    

    bei WordProcessor1.h keine fehler

    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Biblio8hkes pou apetounte epipleon.									//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    //#if_not_define
    //#include <stdio.h>
    //#include <stdio.h>
    //#end_if
    
    //Apari8mhtoi tupoi dedomkenon
    
    #define MaxLine 100
    #define MaxLetter 10
    // sunolika 100*30*(char) = 24.000 byte
    typedef char Type;
    //typedef Type Line[MaxLetter]; den sumferi
    
    //Telos apari8mhtoi tupoi dedomenon
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //						Kataskeuh Domes									//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    //apo8hkeuh to mege8os tou pinaka
    typedef struct _TFS //gia Text File Size
    {
    	int LetterSize;
    	int LineSize;
    }TFS;
    
    //apo8hkeuh olo to keimeno
    typedef struct _SFTF //gia struct for Text File
    {
    	TFS VSize; //int Size;
    	Type String[MaxLine][MaxLetter];
    }SFTF;
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //				telos kataskeuh domhs									//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    /*
    **************************************************************************
    *																		 *
    *						BASIKES PRAKSEIS								 *
    *																		 *
    **************************************************************************
    */
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	Dhmeiourgh mia kenh sumbolosira, bazontas os mege8os ena//
    //	noumero.															//
    //																		//
    //	Eisodos	:	Ton ATD													//
    //																		//
    //	Exodos	:	Arxikopoihsh ths shmboloseiras.							//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    void Create(SFTF *Word);
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	Epistrefi ton i-osto xaraktira.							//
    //																		//
    //	Eisodos	:	Ton ADT.												//
    //																		//
    //	Exodos	:	Epistrofi tou i.										//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    Type Anakthsh(SFTF CopyWord, int Line, int Letter);
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	Topo8eth ena do8en xaraktira sto telos tou ATD.			//
    //																		//
    //	Eisodos	:	Ton ATD.												//
    //																		//
    //	Exodos	:	Epistrefi ena neo ATD.									//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    void Prosartisi(SFTF *Word, Type Letter);
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	Diagrafi ton proto xarkthra mias sumboloseiras, omos h  //
    //	h sumboloseira apath na mhn einai kenh.								//
    //																		//
    //	Eisodos	:	Thn sumboloseira.										//
    //																		//
    //	Exodos	:	Thn sumboloseira opou aferthike o protos xaraktiras.	//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    void Diagrafi(SFTF *Word);
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	Dexete thn sumboloseira kai epistrefi to pli8os ton		//
    //				gramon.													//
    //																		//
    //	Eisodos	:	Thn symboloseira.										//
    //																		//
    //	Exodos	:	To plithos ton gramon									//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    int GetLine(SFTF CopyWord);
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	Dexete thn sumboloseira kai epistrefi to pli8os ton		//
    //				gramaton pou briskonte sthn seira.						//
    //																		//
    //	Eisodos	:	Thn symboloseira.										//
    //																		//
    //	Exodos	:	To plithos ton gramon									//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    int GetLetter(SFTF CopyWord);
    
    /*
    **************************************************************************
    *																		 *
    *					   Sun8etes Prakseis								 *
    *																		 *
    **************************************************************************
    */
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	Einai genikeush ths anakthseis Antigrafei ena			//
    //				sungekrimeno plh8os xarakthron se mia allh sumboloseira //
    //																		//
    //	Eisodos	:	Ton ATD.												//
    //																		//
    //	Exodos	:	ADT alagmeno.											//
    //																		//
    //	Sumeiosh:	Apethte prota dimiourgua tou ATD me thn katalilh		//
    //				sunarthsh kai isxh CopyWord, 1 <= Possition <= n		//
    //				1<= n <= Max											//
    //																		//																		//
    //////////////////////////////////////////////////////////////////////////
    
    void Antigrafh(SFTF CopyWord, int Position, int n, SFTF *NewWord);
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	Einai genhkeush ths Prosarthseis. topo8eth mia			//
    //				sumboloseira sto telos mias allhs.						//
    //																		//
    //	Eisodos	:	duo ATD.												//
    //																		//
    //	Exodos	:	ton Main ATD											//
    //																		//
    //	Shmeiosh:	Leitourgh antisthxa san sunenosh pinakon, mono pou		//
    //				to periexomeno ths mia topo8ethte sto telos ths allhs.	//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    void Fousion(SFTF *pWord1, SFTF Word2);
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	Entopizei thn afeteria mias sumbolosuras pou briskete	//
    //				entos mias allhs.										//
    //																		//
    //	Eisodos	:	duo ATD.												//
    //																		//
    //	Exodos	:	ena akereo an -1, h simboloseira pou singrinete einai   //
    //				adia. Epistrefh -2 an h sumboloseira pou prepei na brefh//
    //				ksepernaei kapia oria. An epistrefh 0 den bre8h. An 1	//
    //				h thmei pou epistra8hke bre8hke to stoixeio.			//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    int LSeek(SFTF Word, SFTF SeekWord, int *i, int *j);
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	Topo8eth mia sumboloseira entos mias allhs se ena		//
    //				sungekrimeno seimio.									//
    //																		//
    //	Eisodos	:	2 ATD's.												//
    //																		//
    //	Exodos	:	Ena ATD pou exei ginh oi sunenosh.						//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    void Eisagogh(SFTF *pWord, SFTF ToInLines, int Possition);
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	Diagrafei n grammes apo to keimeno mas, apo thn 8esh m	//				//
    //																		//
    //	Eisodos	:	Ton ATD.												//
    //																		//
    //	Exodos	:	Ton idio ATD me diagrafomenes grammes.					//
    //																		//
    //	Shmeiosh:	n m, h opoia diagrafei n grammes apo to keimeno,		//
    //				ksekinontas apo thn grammh m. Sthrizete sthn ....		//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    void LineDelete(SFTF *Word, int n, int m);
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	tiponh to keimeno n grammes apo to keimeno ksekinontas	//
    //				apo thn grammh m.										//
    //																		//
    //	Eisodos	:	Ton ATD.												//
    //																		//
    //	Exodos	:	Minimata.												//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    void MPrint(SFTF CopyWord, int n, int m);
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	n sumboloseira1 sumboloseira2, h opoia antika8hsta ka8e //
    //				sumboloseira1 sthn grammh n me th sumboloseira2.	(SFTF *pWord1, SFTF Word2)	//
    //																		//
    //	Eisodos	:	Ton ATD.												//
    //																		//
    //	Exoods	:	Neo ATD.												//
    //																		//
    //	Seimiosh:	Praksh ths Antikatastashs, antika8hsta ena tmha ths		//
    //				sumboloseiras me mia allh.								//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    void Antikatastash(SFTF *Word, SFTF InsertWord);
    
    /*
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	n sumboloseira, h opoia tuponh ton ari8mo grammhs kai ta//
    //				periexomena ka8e grammhs, meta th grammh n, pou periexei//
    //				th sumboloseira.										//
    //																		//
    //	Eisodos	:	Ton ATD.												//
    //																		//
    //	Exodos	:	Sthn o8onh.												//
    //																		//
    //	Seimiosh:	...														//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    void FullPrint(SFTF Word, int Line);
    
    */	
    //////////////////////////////////////////////////////////////////////////
    /////////////////////////////End Header File//////////////////////////////
    //////////////////////////////////////////////////////////////////////////
    

    bei WordProcessor1.c

    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	Dhmeiourgh mia kenh sumbolosira, bazontas os mege8os ena//
    //	noumero.															//
    //																		//
    //	Eisodos	:	Ton ATD													//
    //																		//
    //	Exodos	:	Arxikopoihsh ths shmboloseiras.							//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    void Create(SFTF *pWord)
    {
    	pWort->VSize.LetterSize = 0;
    	pWort->VSize.LineSize = 0;
    }
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	Dexete mia sumboloseira kai episrefi th grames ths,		//
    //	dhladh to plhthos ton seiron ths.									//
    //																		//
    //	Eisodos	:	Ton ADT.												//
    //																		//
    //	Exodos	:	Plhthos ton xarakthron.									//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    int GetLine(SFTF CopyWord)
    {
    	return ( CopyWord.VSize.LineSize );
    }
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	Dexete thn sumboloseira kai epistrefi to pli8os ton		//
    //				gramaton pou briskonte sthn seira.						//
    //																		//
    //	Eisodos	:	Thn symboloseira.										//
    //																		//
    //	Exodos	:	To plithos ton gramon									//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    int GetLetter(SFTF CopyWord)
    {
    	return ( CopyWorld.VSize.LetterSize );
    	//return ( ceil( (CopyWord.Size)/MaxRow );
    }
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	Epistrefi ton i-osto xaraktira sthn j-osti seira		//
    //																		//
    //	Eisodos	:	Ton ADT.												//
    //																		//
    //	Exodos	:															//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    Type Anakthsh(SFTF CopyWord,int Line, int Letter)
    {
    
    					//Kurio Programma
    
    	//Elenxos an exei stoixeio h grammi. 
    	if( (0 <= Line) && ( Line <= GetLine(CopyWord) )
    	{
    		//Elenxos an uparxei to gramma.
    		if( (0<=Letter) && ( Letter <= GetLetter(CopyWorld)) )
    		{
    			//Dhnei piso to gramma an uparxei.
    			return CopyWord.String[Line][Letter];
    		}
    		else
    		{
    			//la8os den uparxei gramma ekei omos hparxei grammi.
    			printf("!!!Fatal Error!!!, Q 000 001\n");
    			return ('\0');
    		}
    	}
    	else
    	{
    		//La8os den uparxei oute grammi oute gramma.
    		printf("!!!Fatal Error!!!, Q 000 000\n");
    	}
    }
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	Diagrafi ton proto xarkthra mias sumboloseiras, omos h  //
    //	h sumboloseira apath na mhn einai kenh.								//
    //																		//
    //	Eisodos	:	Thn sumboloseira.										//
    //																		//
    //	Exodos	:	Thn sumboloseira opou aferthike o protos xaraktiras.	//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    void Diagrafi(SFTF *Word)
    {
    	//Dhlosh Metablhton
    	int i;	// i stoixeio
    	int j;	//j grammei 
    //
    	i=0;
    	j=0;
    
    			//Kurio Programma
    
    	//Elenxos an einai kenh h sunboloseira
    	if(GetLine(*Word)==0 && GetLetter(*World)==0)//Kenh
    	{
    		printf("Kenh sumboloseira\n.");
    		printf("error Q 000 spezial");
    	}
    	else//mh kenh
    	{
    		//Antigrafi tou n+1 sto n.
    		for(i=0; i < GetLine(Word);i++)
    		{
    			//Periptosh an h k grammi exei 0 stoixeia.
    			if(GetLetter(Word) == 0)
    			{
    				Word->String[i-1][MaxLetter] = Word->String[i][0];
    			}//End if
    
    			for(j=0; j < GetLetter(Word); j++)
    			{
    
    				Word->String[i][j]=Word->String[i][j+1];
    			}//end for
    
    /*La8os isos?
    			if(GetLine(*World) != 0)
    			{
    				Word->String[i-1][MaxLetter] = Word->String[i][0];
    			}//end if
    La8os isos?*/
    
    		}// end for
    		//Aferesi mias monadas apo to sinoliko mege8os 		
    	}//end if
    }//enr funktion
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	Topo8eth ena do8en xaraktira sto telos tou ATD, epeishs	//
    //				elenxh an einai gemath h sumboloseira mas.				//
    //																		//
    //	Eisodos	:	Ton ATD.												//
    //																		//
    //	Exodos	:	Epistrefi ena neo ATD.									//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    void Prosartisi(SFTF *Word, Type Letter)
    {
    	//Kurio Programma
    
    	//Elenxos an einai gemati h sumboloseira mas.
    	if( (GetLine(*Word) == MaxLine) && (GetLetter(*Word) == MaxLetter) )
    	{
    		printf("Gemati sumboloseira\n");
    	}
    	else
    	{
    		//Elenxos an h gramh einai gemati gia arxh neas grammeis.
    		if(GetLetter(*Wort) == MaxLetter)
    		{
    			Word->VSize.LineSize++;
    			Word->VSize.LetterSize=0;
    		}
    		//Apo8hkeuh sthn epomenh 8esh to gramma.
    		Word->String[LineSize][LetterSize]=Letter;
    	}
    }
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	Einai genikeush ths anakthseis Antigrafei ena			//
    //				sungekrimeno plh8os xarakthron se mia allh sumboloseira //
    //																		//
    //	Eisodos	:	Ton ATD.												//
    //																		//
    //	Exodos	:	ADT alagmeno.											//
    //																		//
    //	Sumeiosh:	Apethte prota dimiourgua tou ATD me thn katalilh		//
    //				sunarthsh kai isxh CopyWord, n plh8os grammon			//
    //				Possition apo 8esh.											//
    //																		//																		//
    //////////////////////////////////////////////////////////////////////////
    
    void Antigrafh(SFTF CopyWord, int Position, int n, SFTF *NewWord)
    {
    	//Dhlosh Metablhton
    	int LastLine;//H teleutaia grammh pou prepeina antigrafh
    	int i;		 //i grammh
    	int j;		 //j seira
    //
    	LastLine=0;
    
    			//Kurio Meros
    
    	if(Position > GetLine(CopyWord)
    	{
    		printf("Den exei nohma h antigrafi");
    	}
    	else
    	{
    		if(n+Position < GetLine(CopyWord) )
    		{
    			printf("Den einai dinaton na antigrafoun tosa stoixeia\n");
    		}
    		else
    		{
    			LastLine=Possition+n-1;//An den leitourgei einai afto la8os
    			Create(NewWord);	   //Arxikopoihs tou NewWord
    
    			//Arxizei h antigrafh apo seira seira kai stoixeio se stoixeio
    			for(i=Possition; i < LastLine; i++)
    			{
    				for(j=0; j < MaxLetter; j++)
    				{
    			//Xrisimopoio thn Prosarthsh gia thn antigrafh ana sumbolo
    					Prosartisi(NewWord,Anakthsh(CopyWord,i,j);
    				}
    			}
    		}
    	}
    }
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	Einai genhkeush ths Prosarthseis. topo8eth mia			//
    //				sumboloseira sto telos mias allhs.						//
    //																		//
    //	Eisodos	:	duo ATD.												//
    //																		//
    //	Exodos	:	ton Main ATD											//
    //																		//
    //	Shmeiosh:	Leitourgh antisthxa san sunenosh pinakon, mono pou		//
    //				to periexomeno ths mia topo8ethte sto telos ths allhs.	//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    void Fousion(SFTF *pWord1, SFTF Word2)
    {
    	//Dhlosh Metablhton
    //	SFTF TempWord;	//Metablhth Prosorini
    //
    //	Create(TempWord);
    
    		//Kurio Meros
    
    	//elenxos an einai dinaton h sunenosh
    	if( (GetLine(Word2) == 0) && (GetLetter(Word2) == 0)
    	{
    		printf("Den uparxoun stoixeia gia antigrafh\n");
    	}
    	else
    	{
    		if( (GetLine(*Word1)+GetLine(Word2)) > MaxLine)
    		{
    			printf("Adinaton na pragmatopoih8h h sunenosh!.\n");
    		}
    		else
    		{
    			Antigrafh(Word2,GetLine(*pWord1),GetLine(*pWord2),pWord1);
    		}
    	}
    }
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	Entopizei thn afeteria mias sumbolosuras pou briskete	//
    //				entos mias allhs.										//
    //																		//
    //	Eisodos	:	duo ATD.												//
    //																		//
    //	Exodos	:	ena akereo an -1, h simboloseira pou singrinete einai   //
    //				adia. Epistrefh -2 an h sumboloseira pou prepei na brefh//
    //				ksepernaei kapia oria. An epistrefh 0 den bre8h. An 1	//
    //				h thmei pou epistra8hke bre8hke to stoixeio. Epistrefi	//
    //				episeis kai thn 8esh se suntetagmenes					//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    int LSeek(SFTF Word, SFTF SeekWord, int *i, int *j)
    {
    
    	//Dhlosh sunarthseon
    	int LineWord;		//Dixths grameis tou Word
    	int	LetterWord;		//Dixtis grammatos tis seiras tou Word
    	int LineSeekWord;	//Dixths grameis tou SeekWord
    	int LetterSeekWord;	//Dixths grammatos tis seiras tou SeekWord
    	int MaximumLetter;
    	int Status;			//An brefike h oxi
    //
    	LineWord=0;
    	LetterWord=0;
    	LineSeekWord=0;
    	LetterSeekWord=0;
    	MaximumLetter=MaxLetter;//Arxikopoihte me to maxletter
    	Status=0;
    
    		//Kurio Programma
    	if( (GetLetter(SeekWord) == 0) && (GetLine(SeekWord) == 0) )
    	{
    		return -1;
    	}
    	else
    	{
    		if( (GetLetter(SeekWord) + GetLine(SeekWord)) > (GetLetter(Word) + GetLine(Word)) )
    		{
    			return -2;
    		}
    		else
    		{
    			//Metakinoume tous dixtes tou Word, gia ton elexo ton stoixeio
    			for(LineWord=0; (LineWord < GetLine(Word)) && (LineSeekWord < GetLine(SeekWord)); LineWord++)
    			{
    				//Gia thn teleutaia seira tou keimenou pou den einai plires
    				if(LineWord == (GetLine(Word)-1)
    				{
    					MaximumLetter=GetLetter(Word)+1;
    				}
    				else
    				{
    					for(LetterWord=0;( (LetterWord < MaximumLetter) && (LetterSeekWord < GetLetter(SeekWord) ); LetterWord++)
    					{
    						//Elenxos ths or8othtas
    						if( (Anakthsh(Word,LineWord,LetterWord) == (Anakthsh(SeekWord,LineSeekWord,LetterSeekWord) )
    						{
    							//An ali8eis aufksanh kata ena to Counter oste
    							//na elexth to epomenh stoixeio
    							LetterSeekWord++;
    
    							//An LetterSeekWord ginei ish ne max. tote
    							//apethte nea grammh.
    							if(LetterSeekWord == MaxLetter)
    							{
    								//Auksanh grammh
    								LineSeekWord++;
    								//resset grammh
    								LetterSeekWord=0;
    							}
    							Status=1;
    						}
    						else
    						{
    							LineSeekWord = 0;
    							LetterSeekWord = 0;
    							Status=0;
    						}//end if
    					}//end for
    				}//end else
    			}//end for
    			//Epistrefh thn 8esh tou dixth thsgrammh
    			*i=LineWord;
    			//Epistrefh thn 8esh tou dixth tou grammatos
    			*j=LetterWord;
    			//Epistrefh thn katastash an bre8hke h oxi hz sumboloseira.
    			return (Status);
    		}//End else
    	}//End Else
    }
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	n sumboloseira1 sumboloseira2, h opoia antika8hsta ka8e //
    //				sumboloseira1 sthn grammh n me th sumboloseira2.		//
    //																		//
    //	Eisodos	:	Ton ATD.												//
    //																		//
    //	Exoods	:	Neo ATD.												//
    //																		//
    //	Seimiosh:	Praksh ths Antikatastashs, antika8hsta ena tmha ths		//
    //				sumboloseiras me mia allh.								//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    void Antikatastash(SFTF *Word, SFTF InsertWord)
    {
    		//Dhlosh Metablhton
    	int i;				//i seira
    	int j;				//j stoixeio
    	int Correctness;	//An uparxei afto pou psaxnoume
    //
    	i=0;
    	j=0;
    	Correctness=0;
    
    				//Kurio Programma
    	Corectness=LSeek(Word,InsertWord,&i,&j);
    
    	//An bre8hke
    	if( Corectness == 1)
    	{
    		LineDelete(Word,i,GetLine(InsertWord);
    		Eisagogh(Word,InsertWord,i);
    	}
    	else
    	{
    		printf("H Antikatastash apothxe\n");
    	}
    }
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	Topo8eth mia sumboloseira entos mias allhs se ena		//
    //				sungekrimeno seimio.									//
    //																		//
    //	Eisodos	:	2 ATD's.												//
    //																		//
    //	Exodos	:	Ena ATD pou exei ginh oi sunenosh.						//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    void Eisagogh(SFTF *pWord, SFTF ToInLines, int Possition)
    {
    	//Dhlosh Metablhton
    	SFTF TempWord;
    //
    	Create(*pWord);
    
    			//Kuria Sunarthsh
    
    	if( (GetLine(*pWord)+GetLine(ToInLines)) > MaxLine )
    	{
    		printf("Den ginete h eisagogh\n");
    	}
    	else
    	{
    		//Prota antigrafoume olla ta stoixeia os Possition-1
    		Antigrafh(*pWord,0,Possition-1,&TempWord);
    		//Meta kanoume sunenosh ths Prosorinis me to pli8os ton seiron pou
    		//8eloume na eisagoume
    		Fousion(&TempWord2,ToInLines);
    		//Kanoume kai telikh antigrafh
    		Antigrafh(*pWord,Possition,GetLine(CopyWord),&TempLine);
    		//Apetite telika kai h antigrafh apo Temp sthn Word oste
    		Antigrafh(TempWord,0,GetLine(CopyWord),pWord);
    	}
    }
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	Diagrafei n grammes apo to keimeno mas, apo thn 8esh m	//				//
    //																		//
    //	Eisodos	:	Ton ATD.												//
    //																		//
    //	Exodos	:	Ton idio ATD me diagrafomenes grammes.					//
    //																		//
    //	Shmeiosh:	n m, h opoia diagrafei n grammes apo to keimeno,		//
    //				ksekinontas apo thn grammh m. Sthrizete sthn ....		//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    void LineDelete(SFTF *Word, int n, int m)
    {
    	//Dhlosh Metablhton
    	SFTF Temp1Word;
    	SFTF Temp2Word;
    //
    	Create(&Temp1Word);
    	Create(&Temp2Word);
    
    		//Kurio Meros
    
    	//Elenxos isodos dedomenon
    	if( (m == 0) || (n==0) || ( (m+n) > (MaxLine) ) )
    	{
    		printf("H diagrafh den exei nohma\n");
    	}
    	else
    	{
    		//arxika aferoume mia monada apo m gia na ftasoume se pliroforiako
    		//m, etsi
    		--m;
    		//antigrafoume to periexomeno to ATD apo 0 os m-1.
    		Antigrafh(*Word,0,m-1,&Temp1Word);
    		//antigrafoume to periexomeno apo ATD apo m+n os telos stoixeion.
    		Antigrafh(*Word,m+n,GetLine(*Word),&Temp2Word);
    		//sbinoume OLLO to periexomeno tou Word
    		Create(Word);
    		Fousion(Word,Temp1Word);
    		Fousion(Word,Temp2Word);
    	}
    }
    
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	tiponh to keimeno n grammes apo to keimeno ksekinontas	//
    //				apo thn grammh m.										//
    //																		//
    //	Eisodos	:	Ton ATD.												//
    //																		//
    //	Exodos	:	Minimata.												//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    void MPrint(SFTF CopyWord, int n, int m)
    {
    	//Metablhtes
    	int CounterLine;//Posses grames exoun ektipo8h;
    	int CounterChar;
    	Type TempChar;
    //
    	CounterLine=m;
    
    			//Kuria sunarthsh
    
    	//Elenxh an exei nohma o do8en ari8mos siron na ektipo8h
    	if(n>0)
    	{
    		//Elenxh an uparxei exei stoixeia h seira apo thn opoia arxizei
    		//h ektiposh.
    		if(m<=GetLine(CopyWord)
    		{
    		//Elenxh an hparxh teoio megalo n gia na ektipo8h
    			if( n+m>GetLine(CopyWord) )
    			{
    				printf("Den uparxoun sinolika toses grammes gia ektiposh\n");
    				printf("Ektipononte h %d",MaxLine-m);
    				//Apo8hkeush neas timh sto m
    				n=MaxLine-m;
    			}
    			else
    			{
    				while(CounterLine != (n+m)
    				{
    					if(CounterLine != GetLine(CopyWorld)
    					{
    						for(CounterLetter=0;CounterLetter<MaxLetter;CounterLetter++)
    						{
    							printf("%c",&Anakthsh(CopyWord,CounterLine,CounterLetter);
    						}
    						printf("\n");
    						//Auksani to ari8mo oste na ginh kapote ish kai na
    						//samtish h ektiposh
    						CounterLine++;
    					}
    					else
    					{
    						for(CounterLetter=0;CounterLetter<CounterLetter(World);CounterLetter++)
    						{
    							printf("%c",&Anakthsh(CopyWord,CounterLine,CounterLetter);
    						}
    					}
    				}
    			}
    		}
    		else
    		{
    			printf("Den exei nohma na ektipo8oun h grammes(kenes)");
    		}
    	}//end 1.if den exei nohma na ektipo8h h grammh
    	else
    	{
    		printf("La8os epilogh\n");
    	}
    }
    
    /*		
    //////////////////////////////////////////////////////////////////////////
    //																		//
    //	Skopos	:	n sumboloseira, h opoia tuponh ton ari8mo grammhs kai ta//
    //				periexomena ka8e grammhs, meta th grammh n, pou periexei//
    //				th sumboloseira.										//
    //																		//
    //	Eisodos	:	Ton ATD.												//
    //																		//
    //	Exodos	:	Sthn o8onh.												//
    //																		//
    //	Seimiosh:	Apetite h sunarthsh MPrint.								//
    //																		//
    //////////////////////////////////////////////////////////////////////////
    
    void FullPrint(SFTF CopyWord, int Line)
    {
    			//Kurio Programma
    
    	//Ektiponh ton ari8mo grammeis
    	printf("Ari8mo Grammis %d\n\n\n", &Line);
    
    	//Sinartish pou ektiponh olles ths grammes os to telos
    	MPrint(CopyWord, Line, GetLine(CopyWorld));
    }
    */
    


  • HAbs danke, aber wiso muss ich so machen?, hab noch mein programm reingemacht mit vielen fehler leider, Type damit das programm schon abstract ist ?!?( 🤡 wer weis 🤡 )?!?


Anmelden zum Antworten