Created
April 13, 2016 17:19
-
-
Save anonymous/e9eae896e9fb2854b89a05b241984243 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 count = 1; | |
char category[25] = "String"; | |
char item[25] = "String"; | |
float quantity[50]; | |
myArray[4][4][1] = { | |
{category1, item1, quantity1} , | |
{categorry2, item1, quuantity2} , | |
{category3, item3, quantity3}, | |
{category4, item4, quantity4} | |
}; | |
for( ; ; ) { | |
count = count +1; | |
printf("enter category "); | |
gets(category); | |
printf("enter item "); | |
gets(item); | |
printf("enter quantity "); | |
gets(quantity); | |
printf("%d\n", count); | |
strcpy(myArray[0][0][0], category+count, item+count, quantity+count); | |
/* | |
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