Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*age check (c) By Tim Hartmann*/
- #include <stdio.h>
- #include <stdlib.h>
- #include <conio.h>
- #include <windows.h>
- #include <time.h>
- #include <string.h>
- int main ()
- {
- SetConsoleTitle(" Age Check! ");
- SYSTEMTIME time;
- GetSystemTime (&time);
- char name[20], bday[13], bjahr[5], bmonat[3], btag[3];
- char *bump;
- int year = time.wYear;
- int month = time.wMonth;
- int day = time.wDay;
- int intjahr, intmonat, inttag, alter;
- begin:
- printf("\n\n Heute ist der: %i.%i.%i \n\n",day,month,year);
- printf(" Bitte ein Geburtsdatum eingeben. (tt.mm.jjjj).\n\n");
- bump=&bday;
- bday[0]='.';
- bump++;
- fgets(bump,sizeof(bday)-1, stdin);
- if(strlen(bday) < 12){
- printf("\n\n ungueltiges Datum!\n\n");
- system("pause");
- system("cls");
- goto begin;
- }
- strncpy(bjahr , &bday[7], 4);
- bjahr[4] = '\0';
- strncpy(bmonat, &bday[4], 2);
- bmonat[2]= '\0';
- strncpy(btag , &bday[1], 2);
- btag[2] = '\0';
- intjahr = atoi(bjahr) ;
- intmonat = atoi(bmonat);
- inttag = atoi(btag) ;
- if((intjahr > year) || (intmonat > 12) || (inttag > 31)){
- printf("\n\nungueltige einabe \n\n");
- getchar();
- system("cls");
- goto begin;
- }
- alter=year-intjahr;
- if((intmonat==month) && (inttag==day)){
- printf("\n\n Happy Birtday, Ich glaube ich muss dir nicht sagen wie alt du bist oder?"
- "\n nagut, du bist %i geworden\n\n",alter);
- system("pause");
- system("cls");
- goto begin;
- }
- if((intmonat <= month) && (inttag <= day)){
- if(alter==1){
- printf("\n\n Diese Person ist 1 Jahr alt\n\n\n");
- system("pause");
- exit(1);
- }
- printf("\n\n Diese Person ist %i Jahre alt.\n\n",alter);
- }
- else{
- printf("\n\n Diese Person ist %i Jahre alt.\n\n",alter-1);
- }
- system("PAUSE");
- system("cls");
- goto begin;
- }
Advertisement
Add Comment
Please, Sign In to add comment