int main(void) { printf ("Welcome, please enter the following information:\n"); printf ("1. Name of Pizza Company\n2. Diameter of it's Pizza\n3. Weight of it's Pizza\n"); fillStruct(Pizza); displayStruct(Pizza); }
VersionStruct* Version::getStruct() { VersionStruct *version = new VersionStruct(); fillStruct(version); return version; }
int main() { FILE *fp; FILE *fout; fout=fopen("Assignment1.txt","w"); fp=fopen("a1.txt","r"); int numLines=0, numEntries=0; struct person personList; struct person MyPerson; printf("How many people are in the file?"); scanf("%d",&numEntries); numLines=fillStruct(fp,personList); setPerson(fout,personList); printStructArray(fout,personList,numLines); fclose(fp); fclose(fout); return 0; }
int main(int argc, char** argv) { int i; int index = 0; int fd; char *buffer = (char*) calloc(1024, sizeof(char)); char *tmp = (char*) calloc(1024, sizeof(char)); ligne *l = NULL; if(argc == 1) { printf("Use : %s [filename]\n", argv[0]); return EXIT_FAILURE; } fd = open(argv[1], O_RDONLY); if(fd <= 0) { printf("Couldn't open %s\n", argv[1]); return EXIT_FAILURE; } bin_line *l1 = (bin_line*) calloc(1, sizeof(bin_line)); bin_line *l2 = (bin_line*) calloc(1, sizeof(bin_line)); l1->position = END; l2->position = BEGIN; int nb_lus; int tic = 0; nb_lus = read(fd, buffer, 1023); do { if(!newLineBeforeEnd(buffer, 1024, index)) { for(i=index; i<1024; i++) tmp[i-index] = buffer[i]; nb_lus = read(fd, tmp + (1024 - index), 1024 - 1); buffer = tmp; index = 1; } /* write(STDOUT_FILENO, buffer, 1023); */ if(nb_lus == 0) break; l = getLine(buffer, &index); if(tic % 2 == 0) fillStruct(l, l1); if(tic % 2 == 1) { fillStruct(l, l2); combineTwoLines(l1, l2); } /*if(l != NULL) printLine(l);*/ index++; tic++; } while(l != NULL); /* printLine(getLine(buffer, &index)); index++; printLine(getLine(buffer, &index)); print_long_long_int_bin(tmp); printf("\n"); print_long_long_int_bin(tmp << 4); printf("\n"); print_chars((char*)(&tmp), 8); */ /* int i; tmp <<= 4; for(i=0; i<8; i++) printf("%c", ((char*) (&tmp))[7-i]); */ /* int t = 1023; printf("%c", combine_two(0b11110010, 0b11001100, 3)); printf("%c%c", ((char*) (&t))[0], ((char*) (&t))[1]); */ /* read(fd, buffer, 1023); do { if(index > (1023 - 316)) { for(i=index; i<1023; i++) tmp[i - 1023 + index] = buffer[i]; } buffer = tmp; read(fd, buffer + index, 1023 - index); l = getLine(buffer, &index); } while(l != NULL); */ /* while(getLine(buffer, &index) != NULL) index++; return EXIT_SUCCESS; ligne *l = getLine(buffer, &index); */ /* l1->position = END; fillStruct(l, l1); index++; l = getLine(buffer, &index); l2->position = BEGIN; fillStruct(l, l2); combineTwoLines(l1, l2); */ }