Commit di recap
This commit is contained in:
1 parent
2f967a0fd8
commit
1c17ccc2c7
14 files changed
+75
-4
No files matched your search
+40
-2
@@ -6,9 +6,18 @@
|
||||
#include "../include/logic.h"
|
||||
#include "../include/globals.h"
|
||||
|
||||
FILE *products;
|
||||
/*
|
||||
* TODO: Listare prodotti con prezzo da file
|
||||
* TODO: Aggiungere prodotto con prezzo a file
|
||||
* TODO: Listare copie vendute di prodotto da file
|
||||
* TODO: Aggiungere copie venduto di prodotto a file
|
||||
* TODO: Cambiare nome dei file con interagisce
|
||||
* TODO: Calcolare la somma delle entrate dati i file
|
||||
*/
|
||||
|
||||
int exists(const char *fname) {
|
||||
char *products;
|
||||
|
||||
int existsFile(const char *fname) {
|
||||
FILE *file;
|
||||
if ((file = fopen(fname, "r")))
|
||||
{
|
||||
@@ -18,7 +27,36 @@ int exists(const char *fname) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void createFile(const char *fname) {
|
||||
FILE *file;
|
||||
file = fopen(fname, "w");
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
char* getProducts(const char *fname) {
|
||||
FILE *file;
|
||||
|
||||
if((file=fopen(fname, "r"))==NULL) {
|
||||
printf("Errore nell'apertura del file");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// TODO QUESTO CODICE NON E' MIO, RICONTROLLARE FUNZIONAMENTO fread()
|
||||
|
||||
while(!feof(file)){
|
||||
n = fread(buffer, sizeof(char), sizeof(buffer), file);
|
||||
for (i=0; i<n; i++)
|
||||
if (buffer[i] == c)
|
||||
count++;
|
||||
}
|
||||
fclose(file);
|
||||
|
||||
}
|
||||
|
||||
int getCount(){
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ncurses.h>
|
||||
|
||||
#include "../include/logic.h"
|
||||
#include "../include/globals.h"
|
||||
|
||||
int main() {
|
||||
printf("%d", exists("qwestoeuntest"));
|
||||
createFile("qwestoeuntest");
|
||||
printf("%d", exists("qwestoeuntest"));
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user