#include < stdio.h> #include < stdlib.h> #include < string.h> # define N 4struct ss {// list main contents Sales, products, sales int no; // Sales number int product; // float sales; // Sales}; struct ss fz[N]; // Define a global struct array: fz with four elements, each of which is a struct variable int main(void) {int a, b, s, i, n, j; printf("
Please select the function you want to perform
>
\n\n"); // Output prompt message printf(" If you want to input salesman's note information and save please input: 1\n\n"); printf(" Enter: 2\n\n" to calculate sales per person for each product); printf(" Rank salespeople by sales from highest to lowest please enter: 3\n\n"); printf(" Please enter: 4\n\n" to sort different types of products by sales volume); printf(" To add, delete or modify note information enter: 5\n\n"); printf(" To exit the program or have completed your requirements please enter: 6\n\n"); scanf("%d", & a); switch(a) { case 1: { FILE *fp; // Define file pointer if((fp = fopen(" sales management system design.txt ", "w")) == NULL) {// open file printf(" file cannot open \n"); exit(0); } for(i = 0; i < N; i++) {// enter note information printf(" Please enter %d note information \n", i+ 1); fflush(stdin); printf(" Please enter salesman's ID \n"); scanf( "%d", & fz[i].no); if(fz[i].no > N) {printf(" No salesman number, please re-enter \n")
I want to save to the file, but it doesn't seem to work, I also want to make an input data error and return to the original location and re-enter
0 Answer
No answer yet
这家伙很懒,什么都没留下...