Created
April 13, 2016 13:47
-
-
Save anonymous/8b922b6d8085a7982f6a6672afa9e40f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
/* | |
* | |
*/ | |
int main(int argc, char** argv) { | |
// FILE pWrite; | |
//FILE *pAppend; | |
// FILE *pRead; | |
// FILE *fptr; | |
//char input; | |
// char words; | |
int a = 20; | |
char category[50]; | |
char item[50]; | |
float quantity[50]; | |
int myArray[4][4][1] = { | |
{0, 1, 2} , | |
{3, 4, 5} , | |
{6, 7, 8} | |
}; | |
for( ; ; ) { | |
printf("enter category "); | |
gets(category); | |
printf("enter item "); | |
gets(item); | |
printf("enter quantity "); | |
gets(quantity); | |
/* | |
pRead = fopen("shopping1.txt" , "a"); | |
if(pRead ==NULL) { | |
printf("\nFile could not be opened."); | |
} | |
else { | |
printf("\nFile was opened for reading."); | |
} | |
FILE *fp; printf("\nEnter input: "); | |
char c[] = "\n "; | |
fp = fopen("shopping1.txt", "a"); | |
// Write data to the file | |
fwrite(c, strlen(c) + 1, 1, fp); | |
gets(c); | |
char buffer[1000]; | |
fp = fopen("shopping1.txt", "a"); | |
// Write data to the file | |
fwrite(c, strlen(c) + 1, 1, fp); | |
fseek(fp, SEEK_SET, 0); | |
fclose(fp); | |
if ((fptr=fopen("shopping1.txt","r+"))==NULL){ | |
printf("Error! opening file"); | |
exit(1); // Program exits if file pointer returns NULL. | |
} | |
fscanf(fptr,"%[^\n]",c); | |
fclose(fptr); | |
FILE *f; | |
char h; | |
f=fopen("shopping1.txt","rt"); | |
while((h=fgetc(f))!=EOF){ | |
printf("%c",h); | |
} | |
fclose(f); | |
*/ | |
} | |
return (EXIT_SUCCESS); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment