Programare in C


  1. #1
    0-day Member soulkiller reprezinta o cantitate neglijabila
    Data de inscriere
    08-11-2007
    Varsta
    35
    Sex
    M
    Mesaje
    6
    Mesaje bazar
    7
    Putere Reputatie
    34
    Reputatie
    10
    Puncte CF
    0.0

    Programare in C

    [...]
    edited
    [...]
    Last edited by soulkiller; 26-01-2012 at 00:58.

  2. #2
    Member alex707's Avatar alex707 reprezinta o cantitate neglijabila
    Data de inscriere
    28-09-2006
    Varsta
    43
    Sex
    M
    Mesaje
    183
    Mesaje bazar
    63
    Putere Reputatie
    0
    Reputatie
    8
    Puncte CF
    30.0
    E foarte interesant de implementat ce ai tu aici, din pacate e cam mult de lucru. Nu pot sa-ti promit nimic, dar as putea sa te ajut cu inceputul daca reusesc sa imi fac timp.
    O sa postez aici.
    Success is not final, failure is not fatal: it is the courage to continue that counts. --Sir Winston Churchill
    Vrei mai putine reclame? Inregistreaza-te sau logheaza-te

  3. #3
    Member alex707's Avatar alex707 reprezinta o cantitate neglijabila
    Data de inscriere
    28-09-2006
    Varsta
    43
    Sex
    M
    Mesaje
    183
    Mesaje bazar
    63
    Putere Reputatie
    0
    Reputatie
    8
    Puncte CF
    30.0
    Nu am mai lucrat in C de ceva vreme, in ultimul an am lucrat numai la proiecte in C# si php, asa ca in C sunt foarte rusty. Nu e nevoie sa te superi daca nu te ajuta prea mult, pentru ca asa cum am mai zis inainte este mult de lucru si timpul e intotdeauna greu de gasit .

    In primul rand am vrut sa vad pentru mine cum s-ar incepe o implementare de genul asta neavand de gand sa-l duc pana la capat si in al doilea rand am vazut ca tema asta e folosita pe la o facultate din timisoara, asa ca poate postul asta o sa fie folositor si altora.

    Anyway, asta am facut azi atat cat m-a tinut cheful. Exemplul care urmeaza foloseste un cmd line care accepta doar comanda "hello" implementata intr-o librarie statica iar pentru restul de inputuri afiseaza "command %s not found" (nu am implementat nimic legat de env variables).

    cmd.c
    Cod:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include "library.h"
    
    char c = '\0';
    static char *my_argv[100];
    
    void fill_argv(char *tmp_argv)
    {
            char *foo = tmp_argv;
            int index = 0;
            char ret[100];
            bzero(ret, 100);
            while(*foo != '\0') {
                    if(index == 10)
                            break;
    
                    if(*foo == ' ') {
                            if(my_argv[index] == NULL)
                                    my_argv[index] = (char *)malloc(sizeof(char) * strlen(ret) + 1);
                            else {
                                    bzero(my_argv[index], strlen(my_argv[index]));
                            }
                            strncpy(my_argv[index], ret, strlen(ret));
                            strncat(my_argv[index], "\0", 1);
                            bzero(ret, 100);
                            index++;
                    } else {
                            strncat(ret, foo, 1);
                    }
                    foo++;
            }
            my_argv[index] = (char *)malloc(sizeof(char) * strlen(ret) + 1);
            strncpy(my_argv[index], ret, strlen(ret));
            strncat(my_argv[index], "\0", 1);
    }
    
    void free_argv()
    {
            int index;
            for(index=0;my_argv[index]!=NULL;index++) {
                    bzero(my_argv[index], strlen(my_argv[index])+1);
                    my_argv[index] = NULL;
                    free(my_argv[index]);
            }
    }
    
    int main(int argc, char *argv[], char *envp[])
    {
            char *tmp = (char *)malloc(sizeof(char) * 100);
            char *cmd = (char *)malloc(sizeof(char) * 100);
            printf("$>");
            while(c != EOF) {
                    c = getchar();
                    switch(c)
                    {
                            case '\n': if(tmp[0] == '\0') {
                                            printf("$>");
                                      } else {
                                            fill_argv(tmp);
                                            strncpy(cmd, my_argv[0], strlen(my_argv[0]));
                                            strncat(cmd, "\0", 1);
                                            if (strcmp(tmp, "hello") == 0) {
                                                    hello();
                                            }
                                            else {
                                                    printf("command %s not found\n", tmp);
                                            }
                                            free_argv();
                                            printf("$>");
                                            bzero(cmd, 100);
                                      }
                                    bzero(tmp, 100);
                                    break;
                            default: strncat(tmp, &c, 1);
                                    break;
                    }
            }
            free(tmp);
            printf("\n");
            return 0;
    }
    library.c
    Cod:
    #include <stdio.h>
    
    void hello(void) {
      printf("Library called.\n");
    }
    library.h
    Cod:
    /* library.h - library header */
    
    void hello(void);
    Codul e viabil si se poate testa (eu l-am rulat pe un debian ca asta am acum instalat intr-un vm):
    *Pentru libraria statica:
    gcc -Wall -g -c -o library-static.o library.c
    ar rcs library-static.a library-static.o
    *Pentru exemplu:
    gcc -Wall -g -c cmd.c -o cmd.o
    gcc -g -o cmd cmd.o -L. library-static.a

    Poate o sa mai continui daca mai gasesc timp/chef/stare de spirit.

    Am folosit de aici functii de free si arguments (ar fi durat prea mult sa implementez de la 0) si de aici documentatia de librarii.
    Success is not final, failure is not fatal: it is the courage to continue that counts. --Sir Winston Churchill

  4. #4
    0-day Member soulkiller reprezinta o cantitate neglijabila
    Data de inscriere
    08-11-2007
    Varsta
    35
    Sex
    M
    Mesaje
    6
    Mesaje bazar
    7
    Putere Reputatie
    34
    Reputatie
    10
    Puncte CF
    0.0
    thanks, o sa incerc sa ma mai uit...

  5. #5
    Member alex707's Avatar alex707 reprezinta o cantitate neglijabila
    Data de inscriere
    28-09-2006
    Varsta
    43
    Sex
    M
    Mesaje
    183
    Mesaje bazar
    63
    Putere Reputatie
    0
    Reputatie
    8
    Puncte CF
    30.0
    Nu prea e frumos ca ai sters continutul problemeni ... Poate mai interesa si pe altii ...

    Programare in C
    Assignment I
    ------------

    Scope: create a simple command line interpretor, able to interpret a set of internally-implemented commands.

    Your task for this task assignment is to create a simple command line interpretor. The command line interpretor will offer the following facilities:

    * Accept user commands from command line. The interpretor will expose a specific prompt (e.g. '$>') showing that it is prepared to accept a user command.
    * Execute user commands, from the list of accepted commands. The following error situations MUST be considered:
    o Command execution returned an error. The exact error code must be reported.
    o Issued command is not an accepted command. Error information will contain 'offending' command name.
    o Arguments are in a wrong format: the only accepted format is "-o ARG", where ARG is the optional argument of your option. It is not accepted to use the '/' notation for options or the --option long notation for options. These errors should be identified during preprocessing of command line.
    * Maintain and manage some environmental information, including the root directory, current directory, prompt, or environmental variables (some of the implemented commands will address these issues).
    * Offer a command called "help", that will list all available commands with implemented options.
    * Offer a command called "version", that will offer author information, versioning information, and possibly other valuable information.
    * All commands will be implemented as external functions. A library of functions could be developed for this purpose.
    o Each command will accept the main calling convention: int yourCommandFunction (int argc, char *argv[]) ;. Implementation of the additional main parameter (char **envp) is not required.
    o Each command will return success or an error code (see error code manipulation, above).
    o Each command could report additional error information prior to command exit. E.g. a command that opens an existing file will report the fact that the file does not exist or that it has no permission to access the file.

    The following commands must be implemented, along with their parameters (see man help pages for information on each):

    1. The "cat" command. Parameters that need to be implemented are: -b -E -n -s

    2. The "head" command. Parameters that need to be implemented are: -c, -n, -q, -v

    3. The "env" command. Parameters that need to be implemented are: -u

    Additional Requirements (Assignment II)
    ---------------------------------------

    Scope: implementing command line parsing in your simple command line interpretor (previously developed in Assignment #1). Your newly created application will be able now to execute complex command lines.

    The following commands must be implemented, in addition to the commands from Assignment I, along with their parameters (see man help pages for information on each):

    1. The "ls" command. Parameters that need to be implemented are: -l, -s, -a, -F

    2. The "tac" command. Parameters that need to be implemented are: -b, -s

    3. The "dir" command. No parameters need to be implemented.
    ---------------------------------------------------------------------------

    Programul trebuie facut in ANSI C99 sub Ubuntu. Cine ma poate ajuta la asa ceva plz reply sau pm.
    Success is not final, failure is not fatal: it is the courage to continue that counts. --Sir Winston Churchill

  6. #6
    Member alex707's Avatar alex707 reprezinta o cantitate neglijabila
    Data de inscriere
    28-09-2006
    Varsta
    43
    Sex
    M
    Mesaje
    183
    Mesaje bazar
    63
    Putere Reputatie
    0
    Reputatie
    8
    Puncte CF
    30.0
    Am mai continuat astazi la implementare:
    - comanda "help" - arata comenzile disponibile (cat, head, env, version si exit)
    - comanda "help [command]" unde command poate fie cat, head sau env iti arata optiunile disponibile si usage syntax
    - comanda cat cu optiunile -b -E -n sau -s sau orice combinatie intre ele.
    - comanda version, cu un mic text de versiune.

    Cateva mentiuni legate de "help" si "help command". In loc sa pun textul direct in cmd.c sau library.c, ca sa ramana doar cod in c-uri am facut headere pentru fiecare comanda de help cu outputul de xxd.
    Ca sa fiu mai clar:
    - faci un fisier "help" si scrii text in el exact ce vrei sa iti afiseze
    - rulezi xxd -i help help.h, in urma caruia obtii fisierul help.h care contine variabila help (hexadecimal - unsigned char) si help_len (unsigned int) cu lungimea stringului pe care le includ usor unde am nevoie (direct cu #include)

    Cateva precizari/modificari fata de varianta anterioara:
    - bzero este non-standard si am inlocuit-o cu memset
    - in prima varianta era o greseala cand faceam strcmp ca sa vad ce comanda e faceam pe tmp in loc sa fac pe cmd (care era deja parsat cum trebuie)
    - l-am compilat cu -std=C99 ca sa imi arate warning-uri pe sintaxa stricta de c99

    Comenzile de compilare devin:
    - pentru cmd.c: gcc -Wall -std=c99 -g -c cmd.c -o cmd.o && gcc -std=c99 -g -o cmd cmd.o -L. library.a
    - pentru librarie: gcc -Wall -std=c99 -g -c -o library.o library.c && ar rcs library.a library.o

    Nu am considerat ca e nevoie de sintaxa stricta asa ca daca de ex vrei sa faci cat la cmd.c merge oricare din urmatoarele:
    "cat -bE cmd.c"
    "cat cmd.c -bE"
    "cat cmd.c -b -E"
    "cat -b -E cmd.c"
    "cat -b-E cmd.d"

    Este tratat si cazul in care ai un parametru gresit, iti returneaza mesajul "%s not a valid parameter". Tot asa si pentru cazul cand nu exista fisierul "%s file not found".

    Poate o sa mai continui pe viitor.

    Am sa atasez sursele si ca attachment dar le pun si aici:

    cmd.c
    Cod:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include "library.h"
    #include "help/help.h"
    
    char version[] = "1.00b";
    char c = '\0';
    static char *my_argv[100];
    
    void fill_argv(char *tmp_argv)
    {
    	char *foo = tmp_argv;
    	int index = 0;
    	char ret[100];
    	memset(ret, 0, 100);
    	while(*foo != '\0') {
    		if(index == 10)
    			break;
    
    		if(*foo == ' ') {
    			if(my_argv[index] == NULL)
    				my_argv[index] = (char *)malloc(sizeof(char) * strlen(ret) + 1);
    			else {
    				memset(my_argv[index], 0, strlen(my_argv[index]));
    			}
    			strncpy(my_argv[index], ret, strlen(ret));
    			strncat(my_argv[index], "\0", 1);
    			memset(ret, 0, 100);
    			index++;
    		} else {
    			strncat(ret, foo, 1);
    		}
    		foo++;
    	}
    	my_argv[index] = (char *)malloc(sizeof(char) * strlen(ret) + 1);
    	strncpy(my_argv[index], ret, strlen(ret));
    	strncat(my_argv[index], "\0", 1);
    }
    
    void free_argv()
    {
    	int index;
    	for(index=0;my_argv[index]!=NULL;index++) {
    		memset(my_argv[index], 0, strlen(my_argv[index])+1);
    		my_argv[index] = NULL;
    		free(my_argv[index]);
    	}
    }
    
    int main(int argc, char *argv[], char *envp[])
    {
    	char *tmp = (char *)malloc(sizeof(char) * 100);
    	char *cmd = (char *)malloc(sizeof(char) * 100);
            printf("$>");
            while(c != EOF) {
                    c = getchar();
    		switch(c)
    		{
    			case '\n': if(tmp[0] == '\0') {
    					printf("$>");
    				  } else {
    					fill_argv(tmp);
    					strncpy(cmd, my_argv[0], strlen(my_argv[0]));
    					strncat(cmd, "\0", 1);
    					if (strcmp(cmd, "help") == 0) {
    						if (my_argv[1] == '\0') {
    							printf("%s", help_txt);
    						}
    						else {
    							printf(help(my_argv[1]));
    						}
    					}
    					else if (strcmp(cmd, "cat") == 0) {
    						printf(cat(my_argv));
    					}
    					else if (strcmp(cmd, "version") == 0) {
    						printf("cmd version %s", version);
    					}
    					else if (strcmp(cmd, "exit") == 0) {
    						goto out;
    					}
    					else {
    						printf("Command %s not found\n", tmp);
    					}
    					free_argv();
    					printf("$>");
    					memset(cmd, 0, 100);
    				  }
    				memset(tmp, 0, 100);
    				break;
    			default: strncat(tmp, &c, 1);
    				break;
    		}
        }
    	out:
    	free(tmp);
    	printf("\n");
    	return 0;
    }
    library.c
    Cod:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include "help/help_cat.h"
    #include "help/help_head.h"
    #include "help/help_env.h"
    
    char value[1];
    
    char* help(char* command) {
    	if (strcmp(command, "cat") == 0) {
    		return (char*)help_cat;
    	}
    	else if (strcmp(command, "head") == 0) {
    		return (char*)help_head;
    	}
    	else if (strcmp(command, "env") == 0) {
    		return (char*)help_env;
    	}
    	else {
    		memset(value, 0, strlen(command)+25);
    		sprintf(value, "Command %s not recognized\n", command);
    		return value;
    	}
    }
    
    char* cat(char **argv) {
    	int i = 0;
    	int j = 0;
    	unsigned int number = 0;
    	unsigned int number_nonblank = 0;
    	unsigned int squeeze_blank = 0;
    	unsigned int show_ends = 0;
    	unsigned int file_set = 0;
    	FILE* file = NULL;
    	
    	while (argv[i] != '\0') {
    		if (strlen(argv[i]) > 0 && argv[i][0] == '-') {
    			char *foo = argv[i];
    			while (*foo != '\0') {
    				if (*foo != '-') {
    					char par[1];
    					memset(par, 0, 1);
    					strncpy(par, foo, 1);
    					switch (*par) {
    						case 'b':
    							number_nonblank = 1;
    							break;
    						case 'E':
    							show_ends = 1;
    							break;
    						case 'n':
    							number = 1;
    							break;
    						case 's':
    							squeeze_blank = 1;
    							break;
    						case '-':
    							break;
    						default:
    							sprintf(value, "%s not a valid parameter\n", par);
    							return value;
    					}
    				}
    				foo++;
    			}
    		}
    		else if (strlen(argv[i]) > 0 && strcmp(argv[i], "cat") != 0 && file_set == 0) {
    			file = fopen(argv[i], "r");
    			if (file == NULL) {
    				sprintf(value, "%s file not found\n", argv[i]);
    				return value;
    			}
    			file_set = 1;
    		}
    		i++;
    	}
    	i = 1;
    	if (file_set == 1) {
    		char line_buffer[BUFSIZ];
    		char line_number;
    		int first_empty = 0;
    		line_number = 0;
    		while (fgets(line_buffer, sizeof(line_buffer), file)) {
    			if ((number_nonblank == 1 && strlen(line_buffer) != 1) || (number == 1 && number_nonblank == 0)) {
    				++line_number;
    			}
    			if (show_ends == 1) {
    				j = 0;
    				while (line_buffer[j] != '\n') {
    					j++;
    				}
    				line_buffer[j] = '$';
    				line_buffer[j+1] = '\n';
    				line_buffer[j+2] = '\0';
    			}
    			if (squeeze_blank == 1) {
    				if (strlen(line_buffer) == 1 && first_empty == 0) {
    					first_empty = 1;
    				}
    				else if (strlen(line_buffer) != 1 && first_empty == 1) {
    					first_empty = 0;
    				}
    				else if (strlen(line_buffer) == 1 && first_empty == 1) {
    					line_number--;
    					continue;
    				}
    			}
    			if ((number == 1 && number_nonblank == 0) ||
    				(number_nonblank == 1 && strlen(line_buffer) > 1)) {
    				printf("%6d: ", line_number);
    			}
    			printf("%s", line_buffer);
    		}
    	}
    	return value;
    }
    library.h:
    Cod:
    /* library.h - library header */
    
    char* help(char*);
    char* cat(char **argv);
    help.h (pentru exemplificare)
    Cod:
    unsigned char help_txt[] = {
      0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x63, 0x6f,
      0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
      0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
      0x2d, 0x0a, 0x0a, 0x63, 0x61, 0x74, 0x09, 0x43, 0x6f, 0x6e, 0x63, 0x61,
      0x74, 0x65, 0x6e, 0x61, 0x74, 0x65, 0x20, 0x46, 0x49, 0x4c, 0x45, 0x28,
      0x73, 0x29, 0x2c, 0x20, 0x6f, 0x72, 0x20, 0x73, 0x74, 0x61, 0x6e, 0x64,
      0x61, 0x72, 0x64, 0x20, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x2c, 0x20, 0x74,
      0x6f, 0x20, 0x73, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x20, 0x6f,
      0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, 0x0a, 0x0a, 0x68, 0x65, 0x61, 0x64,
      0x09, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x66,
      0x69, 0x72, 0x73, 0x74, 0x20, 0x31, 0x30, 0x20, 0x6c, 0x69, 0x6e, 0x65,
      0x73, 0x20, 0x6f, 0x66, 0x20, 0x65, 0x61, 0x63, 0x68, 0x20, 0x46, 0x49,
      0x4c, 0x45, 0x20, 0x74, 0x6f, 0x20, 0x73, 0x74, 0x61, 0x6e, 0x64, 0x61,
      0x72, 0x64, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, 0x0a, 0x09,
      0x57, 0x69, 0x74, 0x68, 0x20, 0x6d, 0x6f, 0x72, 0x65, 0x20, 0x74, 0x68,
      0x61, 0x6e, 0x20, 0x6f, 0x6e, 0x65, 0x20, 0x46, 0x49, 0x4c, 0x45, 0x2c,
      0x20, 0x70, 0x72, 0x65, 0x63, 0x65, 0x64, 0x65, 0x20, 0x65, 0x61, 0x63,
      0x68, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x61, 0x20, 0x68, 0x65, 0x61,
      0x64, 0x65, 0x72, 0x20, 0x67, 0x69, 0x76, 0x69, 0x6e, 0x67, 0x20, 0x74,
      0x68, 0x65, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x6e, 0x61, 0x6d, 0x65,
      0x2e, 0x0a, 0x09, 0x57, 0x69, 0x74, 0x68, 0x20, 0x6e, 0x6f, 0x20, 0x46,
      0x49, 0x4c, 0x45, 0x2c, 0x20, 0x6f, 0x72, 0x20, 0x77, 0x68, 0x65, 0x6e,
      0x20, 0x46, 0x49, 0x4c, 0x45, 0x20, 0x69, 0x73, 0x20, 0x2d, 0x2c, 0x20,
      0x72, 0x65, 0x61, 0x64, 0x20, 0x73, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72,
      0x64, 0x20, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x2e, 0x0a, 0x0a, 0x65, 0x6e,
      0x76, 0x09, 0x53, 0x65, 0x74, 0x20, 0x65, 0x61, 0x63, 0x68, 0x20, 0x4e,
      0x41, 0x4d, 0x45, 0x20, 0x74, 0x6f, 0x20, 0x56, 0x41, 0x4c, 0x55, 0x45,
      0x20, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x65, 0x6e, 0x76, 0x69,
      0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x61, 0x6e, 0x64, 0x20,
      0x72, 0x75, 0x6e, 0x20, 0x43, 0x4f, 0x4d, 0x4d, 0x41, 0x4e, 0x44, 0x2e,
      0x0a, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x54, 0x68, 0x65,
      0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66, 0x20,
      0x74, 0x68, 0x65, 0x20, 0x61, 0x70, 0x70, 0x2e, 0x0a, 0x65, 0x78, 0x69,
      0x74, 0x09, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x73,
      0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x2e, 0x0a,
      0x0a, 0x46, 0x6f, 0x72, 0x20, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f,
      0x6e, 0x61, 0x6c, 0x20, 0x68, 0x65, 0x6c, 0x70, 0x20, 0x69, 0x6e, 0x70,
      0x75, 0x74, 0x20, 0x22, 0x68, 0x65, 0x6c, 0x70, 0x20, 0x5b, 0x63, 0x6f,
      0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x5d, 0x22, 0x20, 0x77, 0x68, 0x65, 0x72,
      0x65, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20, 0x69, 0x73,
      0x20, 0x6f, 0x6e, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20,
      0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x63, 0x6f,
      0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x0a
    };
    unsigned int help_txt_len = 512;
    help_cat.h, help_head.h si help_env.h le gasesti in atasament.

    Ar fi interesant daca ar avea cineva sugestii de imbunatatire/optimizare, etc.

    Edit:
    Uitandu-ma peste codul de la cat.c (the real one) din codeutils imi dau seama ca exercitiul asta e tema perfecta din punct de vedere al profesorului pentru ca sunt atatea rahaturi de care se poate lega, ca nici nu iti vine sa te apuci sa le rezolvi pe toate, da barem sa mai si ajungi la un cod cat de cat acceptabil (locks, write errors, samd), decat poate daca copiezi codul cu totul din cat.c . Asa ca in nici un caz a nu se considera ca asta ar fi cea mai buna implementare, ci doar una gandita de mine, la care sunt bineveniti sa contribuie si altii.

    src.zip
    Last edited by alex707; 29-01-2012 at 21:12. Motiv: Thoughts
    Success is not final, failure is not fatal: it is the courage to continue that counts. --Sir Winston Churchill

Tags for this Thread

Google+

Cautati logo-ul CraiovaForum?

Iata cateva variante: