|
| 1 | +#include <stdio.h> // Just Basic Input Output Header File |
| 2 | +#include <stdlib.h> // For SYSTEM Command |
| 3 | +#include <conio.h> // For Getch() |
| 4 | +#include <windows.h> // Windows Designed Only Header, This Rips Compatibility. |
| 5 | +#include <time.h> // For Time Display and Such |
| 6 | +#include <string.h> // String Handling for Usage of Structure and Database |
| 7 | + |
| 8 | +int main() |
| 9 | +{ |
| 10 | + SYSTEMTIME GetDate_Local; |
| 11 | + int Year, Batch_Num = 00, BaseStart = 000, YearCont, BaseCont, Batch_NumCont, AutoCheck_Year; |
| 12 | + int line, counter; |
| 13 | + int buffer[100]; |
| 14 | + FILE *fptr; |
| 15 | + FILE *fptr_open; |
| 16 | + fptr = fopen("IDAlgorithm_CheckFile.lmdat", "wb"); |
| 17 | + |
| 18 | + if (fptr == NULL) |
| 19 | + { |
| 20 | + printf("Error!"); |
| 21 | + exit(1); |
| 22 | + } |
| 23 | + /*else |
| 24 | + { |
| 25 | + printf("Checking for Batch Number Saved Data..."); |
| 26 | + while (fgets(line, sizeof(line), fptr)) |
| 27 | + { |
| 28 | + counter++; |
| 29 | + if (i == 9) |
| 30 | + } |
| 31 | + printf("Checking for Base Number Saved Data..."); |
| 32 | + }*/ |
| 33 | + /*printf("Please enter a year"); |
| 34 | + scanf("%d", &Year); |
| 35 | + printf("Please enter batch number, two digits"); |
| 36 | + scanf("%d", &Batch_Num); |
| 37 | + printf("Please enter base hundreth digits"); |
| 38 | + scanf("%d", &BaseStart); |
| 39 | + system("CLS"); |
| 40 | + printf("Processing and Display Output..."); |
| 41 | + YearCont = Year % 100; |
| 42 | + printf("%02d - %d%d\n\n", YearCont, Batch_Num, BaseStart); |
| 43 | + fclose(fptr); */ |
| 44 | + |
| 45 | + //Dependent Year Checker |
| 46 | + |
| 47 | + GetLocalTime(&GetDate_Local); |
| 48 | + AutoCheck_Year = GetDate_Local.wYear % 100; |
| 49 | + printf("Checker Year Report : %02d\n", AutoCheck_Year); |
| 50 | + printf("Batch Number Default Number is %02d\n", Batch_Num); |
| 51 | + printf("Base Number Default Number is %03d\n", BaseStart); |
| 52 | + getch(); |
| 53 | + while (1) |
| 54 | + { |
| 55 | + if (BaseStart == 999) |
| 56 | + { |
| 57 | + printf("%02d%02d%03d\n", AutoCheck_Year, Batch_Num, BaseStart); |
| 58 | + fwrite(&AutoCheck_Year, sizeof(AutoCheck_Year), 1, fptr); |
| 59 | + fwrite(&Batch_Num, sizeof(Batch_Num), 1, fptr); |
| 60 | + fwrite(&BaseStart, sizeof(BaseStart), 1, fptr); |
| 61 | + fwrite("\n", sizeof(char), 1, fptr); |
| 62 | + //fprintf(fptr, "%02d%02d%03d\n", AutoCheck_Year, Batch_Num, BaseStart); For Normal Mode |
| 63 | + Batch_Num++; |
| 64 | + BaseStart = 000; |
| 65 | + } |
| 66 | + if (Batch_Num == 100) |
| 67 | + { |
| 68 | + break; |
| 69 | + } |
| 70 | + printf("%02d%02d%03d\n", AutoCheck_Year, Batch_Num, BaseStart); |
| 71 | + fwrite(&AutoCheck_Year, sizeof(AutoCheck_Year), 1, fptr); |
| 72 | + fwrite(&Batch_Num, sizeof(Batch_Num), 1, fptr); |
| 73 | + fwrite(&BaseStart, sizeof(BaseStart), 1, fptr); |
| 74 | + //fwrite("\n", sizeof(char), 1, fptr); |
| 75 | + //fprintf(fptr, "%02d%02d%03d\n", AutoCheck_Year, Batch_Num, BaseStart); For Normal Mode |
| 76 | + BaseStart++; |
| 77 | + } |
| 78 | + Sleep(2500); |
| 79 | + fclose(fptr); |
| 80 | + fptr_open = fopen("IDAlgorithm_CheckFile.lmdat", "rb"); |
| 81 | + printf("Lets read it from the File!!!"); |
| 82 | + system("CLS"); |
| 83 | + Sleep(2500); |
| 84 | + Sleep(2500); |
| 85 | + counter = 0; |
| 86 | + Batch_Num = 00; |
| 87 | + BaseStart = 000; |
| 88 | + printf("%02d%02d%03d\n", AutoCheck_Year, Batch_Num, BaseStart); |
| 89 | + fseek( fptr, 1, SEEK_SET ); |
| 90 | + while (1) |
| 91 | + { |
| 92 | + if (feof(fptr)) |
| 93 | + { |
| 94 | + break; |
| 95 | + } |
| 96 | + fread(&AutoCheck_Year, sizeof(AutoCheck_Year), 1, fptr); |
| 97 | + fread(&Batch_Num, sizeof(Batch_Num), 1, fptr); |
| 98 | + fread(&BaseStart, sizeof(BaseStart), 1, fptr); |
| 99 | + fread(&BaseStart, sizeof(BaseStart), 1, fptr); |
| 100 | + printf("%d %d %d\n", AutoCheck_Year, Batch_Num, BaseStart); |
| 101 | + counter++; |
| 102 | + } |
| 103 | + fclose(fptr_open); |
| 104 | + return 0; |
| 105 | +} |
0 commit comments