Registration Problem Solved
Posted by Samath
Last Updated: February 29, 2012
  1356

#include<stdio.h>

#include<conio.h>

#include<stdlib.h>

#include<iostream>

#include<ctime>

#include<string>

 

#define FNAME  "saveReg.txt"

 

char fullname[51];

char idnum[15];

char DOB[11];

char address[31];

charRandNum[15];

char Answer;

 

int main(int argc, char *argv[])

{

            FILE *STOCK;

            srand ((unsigned) time(0));

 

for(int i=0; i <10;i++)

{

RandNum[i]=65 + rand()% 26;

}

 

for(;;)

{

                          STOCK = fopen( FNAME, "a");

          if (STOCK == NULL)

    {

        perror("could notopen"FNAME);

        fclose(STOCK);

        exit(1);

    }

           

         printf("\nPlease enter full nameof student: ");

         fflush(stdin);

         scanf("%[^\n]",fullname);

        

         printf("\nPlease enter student idnumber: ");

          fflush(stdin);

         scanf("%s",idnum);


         printf("\nPlease enter theaddress of the student: ");

          fflush(stdin);

          scanf("%[^\n]",address);

     

         printf("\nPlease enter the dateof birth of the student: ");

          fflush(stdin);

         scanf("%s",DOB);

       

        fprintf(STOCK,"Name:%s\n",fullname);

          fprintf(STOCK,"IDNUMBER%s\n",idnum);

          fprintf(STOCK,"ADDRESS:%s\n",address);

          fprintf(STOCK,"DATE OF BIRTH:%s\n",DOB);

          fprintf(STOCK,"Password:%s\n",RandNum);

        fprintf(STOCK,"\n\n\n");

      

      

         printf("\nAny morerecords(y/n):");

          fflush(stdin);

          scanf("%c",&Answer);

      

          if(Answer == 'n' )

          {

            break;

          }

          else

           if(Answer == 'n' )

           {

           continue;

           }

         

           

}

 

 puts("\n\t\t@@@@@@@@@@@@@@*******

@@@@@@@@@@@@@@@******@@@@@@@@@@@@@@@@\n");

    printf("\t\t* Good Bye \t\t*\n");

   puts("\n\t\t@@@@@@@@@@@@@@*******

@@@@@@@@@@@@@@@******@@@@@@@@@@@@@@@@\n");

           

            getch();

            return 0;

}

   
  
 
 
   

 
 
Very well done
 
C++ just isn't my thing, but you code so nicely in it @_@