GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 28-Apr-2008, 04:26
Ali.M.Habib Ali.M.Habib is offline
New Member
 
Join Date: Apr 2008
Posts: 3
Ali.M.Habib is on a distinguished road

what's the wrong in this code please


Sorry it's too long but it gave me the same error : goto hypasses intialization of local variable.

CPP / C++ / C Code:

#include<stdio.h>
#include<conio.h>
#include<string.h>

main()
{
  clrscr();

  int m=0;

  char NAME[10] ;  int spec=0;  char c;   int counter1=0,counter2=0;

  int NO[10]; int n=0; int CONTINUE;

  char mail[40];

  int No1 = 0,IND=0; // to count number of entered @

  int No2 [40]; //to enter the . indices

  int l=0; // used to insert the indices of .

  int counts =0; // used to count the number of . after @

  char verify;

 struct Employee
{

char NAME[3][10];

char NO[3][10];

char mail[3][40];

};

struct Employee E ;


  /* INTIALIZE MY ARRAYS*/

start:


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

E.NAME[m][f]='\0';


for(f=0;f<=39;f++)
E.mail[m][f]='\0';

for(f=0;f<40;f++)
No2[f]=0;


 /* process for entering the name */

 printf("\tthe user name must not be excessed 10 charachter to avoid truncation\t\n ");

 m1:

 printf("\nEnter user name:\t");

 for (int i=0; i< 10; i++)
	{
	   c=getche();

	     spec= c;
//             printf("%f",spec);

	   if (spec == 13)
	      {
		break;

	      }

	   else
	   {
		if ((spec >= 65) && (spec<= 90) || spec==32 )
		{

		E.NAME[m][i]=c;counter1++;

		}

		else
		{
		  printf("\nYOU MUST ENTER CAPITAL CHARACHTERS ONLY");
		  goto m1;
		}



	   }
	}

	if(counter1<5)

	{

	 clrscr();

	 printf("Name sould be mre than 5 charachters"); goto m1;

	}
	 spec=0;


	 if(CONTINUE != 0)

	 goto  place;

/* process for entering the data */

 m2:


 printf("\n Enter the employee phone No\t");

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

 {


     c=getche();

	     spec= c;

    if (spec == 13)   // Exit if user enter 'Enter button'
	      {
	       break;


	      }
	   else
	   {
		if ((spec >= 48) && (spec<= 57))

		{ E.NO[m][r]=spec-48;  counter2++; }

		else
		{
		  printf("\n Invalid phone number");
		  goto m2;
		}



	    }


 }

 if(counter2<5) // test if the user enter a phone number less than 5 Nos
	{

	 clrscr();

	 printf("\nYou must enter a phone nuumber that not less than 5 numbers "); goto m2;

	}





	spec=0;


	if(CONTINUE != 0)

	 goto  verif;

 //   process to enter and check entered mail

  m3:


   printf("\n Enter the email:");


   counts=0;
   No1=IND=0;






   for(i=0;i<40;i++)
   {


     c=getche();

	     spec= c;

	  if (spec == 13)   // Exit if user click 'Enter button'
	      {
	       break;


	      }
	   else
	   {

		if(spec==64)// detect @ location and indecis
		{
		 E.mail[m][i]=c; No1++; IND=i;


		}

		else if(spec==46) // detect dots location
		 {
		   E.mail[m][i]=c; No2[l]=i; l++;


		 }
		 else if ((spec>=48)&&(spec<=57))  E.mail[m][i]=c;
		 else if ((spec>=65)&&(spec<=90))   E.mail[m][i]=c;
		 else if((spec>=97)&&(spec<=122)|| spec ==95 ) E.mail[m][i]=c;

		else
		{
		  printf("\n Email not contain special charachters reinput it ");


		  No1=0;
		  l=0; counts =0;
		  goto  m3;
		}



	    }
      }

	 // test the format [email]xxXX12_.AS@xxx.xx.xx[/email]

	  if ((No1>1)||No1==0)
	  {
	     printf("\n email should contain one @ charachter");

	     goto m3;

	  }

	  else
	  {
	      for(int x =0,l; x< 40 ; x++)
	      {

	       if((No2[x]>IND)&&(No2[x]-IND !=1))

	       counts++;

	       }

	       if(counts ==0)

	       {

	       printf("\n it must have at least one . after @ separated by one charachter");

	       goto m3;

	       }


	  }

		 if(CONTINUE != 0)


	 goto place;


 printf("\t YOU NOW ENTERED THE FOLLOWING DATA :");

 printf("\nEmployee Name:\t");

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

 printf("%c",E.NAME[m][d]);



 printf("\nEmployee phone number:\t");
 for(d=0;d<counter2;d++)
 printf("%i",E.NO[m][d]);


 printf("\nEmployee e-mail:\t");
 for( d=0;d<40;d++)
 printf("%c",E.mail[m][d]);

 place:

	printf("\nClick M to modify this date, or N to continue enter the othe employee data"); char vreify=getche();

	switch(vreify)
	{
	case 'N':
	{
	CONTINUE =0;
	 if (m<3)
	 m++;
	 goto start;


	}
	case 'M':
	{


	s:
	  printf("\nselect which feild you wanna change? \n\tselect 1 for modifying name, 2 for modifying phone No,3 for modifying e-mail,or -1 to exit  ");

	  scanf("%i",&CONTINUE);

	  switch(n)
	  {
	  case 1:
	  goto m1;
	  case 2:
	  goto m2;
	  case 3:
	  goto m3;
	  case -1:
	  break;
	  default: printf("\nWrong selection"); goto s;

	  }

	}



	case 'e':
	break;

       default:
	{
	 printf("\nInvalid charachter");

	 goto place;
	}
     }


getch();return 0;

}

 
 

Recent GIDBlog2nd Week of IA Training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to sort random access file? wmmccoy0910 C Programming Language 12 04-Sep-2006 03:40
Here it is again! 35% - 40% off For Life! my-e-space Web Hosting Advertisements & Offers 0 20-Apr-2006 14:48
Guidelines for posting requests for help - UPDATED! WaltP C Programming Language 0 21-Apr-2005 02:44
something wrong with this code loon MySQL / PHP Forum 5 07-Jul-2003 05:55

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 23:33.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.