Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main(int argc, char* argv[]){
- FILE* in;
- int *n = calloc(1, sizeof(int));
- int* opCode;
- int* operand;
- fptr_t *fp[] = {sum, diff, prod, quot, rem};
- in = fopen(argv[1], "r");
- if(in == NULL){
- fprintf(stderr, "Unable to read from file %s\n", argv[1]);
- exit(EXIT_FAILURE);
- }
- fscanf(in, "%d", n);
- opCode = calloc(n[0], sizeof(int));
- operand = calloc(n[0] + 1, sizeof(int));
- for(int i = 0; i < n[0]; i++){
- fscanf(in, "%d", opCode);
- }
- for(int i = 0; i < (n[0] + 1); i++){
- fscanf(in, "%d", operand);
- }
- //fgets(opCode, 255, in);
- //fgets(operand, 255, in);
- /*for(int i = 0; fscanf(in, "%d", opCode) != '\n'; i++){
- fscanf(in, "%d", opCode);
- }
- for(int i = 0; fscanf(in, "%d", operand) != '\n'; i++){
- fscanf(in, "%d", operand);
- }*/
- printf("%d\n", n[0]);
- for(int i = 0; i < 8; i++){
- printf("%d, %d\n", opCode[i], operand[i]);
- }
- //printf("%d\n", compute(fp, opCode, operand, n[0]));
- free(n);
- free(opCode);
- free(operand);
- fclose(in);
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement