Thread: Help with this function

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    3

    Help with this function

    Hello everone.. Iam having errors while complilimg this function.. Plz help...

    Function :

    Code:
    void new_ticket()
    
    {
    	FILE *fpt;
    	char reserve, p_name,dest;
    	char seat_type,date,time;
    	int p_cost,s,choi;
    	char day;
    	
    	fpt = fopen("Reservation.txt", "a+");
    
    	
    	for ( s=0; s<=50;++s)
    	{
    		printf("\n Do you want to issue a new ticket? Enter Y or N ...");
    		scanf("&#37;c",&reserve);
    		if 
    			reserve =='N'
    			break;
    		
    		else
    		{
    
    			printf ("\n ``````````````````````````````");
    			printf ("\n 1. London- UK");
    			printf ("\n 2. Paris - France");
    			printf ("\n 3. Dubai- UAE");
    			printf ("\n 4. Rome- Italy");
    			printf ("\n 5. Sydney -Australia");
    			printf ("\n Please select a destination..:");
    			scanf("%d",&choi);
    
    			switch (choi)
    			{
    			case '1':
    				dest='London';
    				day='Monday';
    				time=20.45;
    				printf("\n Please select a date:");
    				scanf("%s",&date);
    				printf("\n Please select the type of seat: T for tourist and F for first class");
    				scanf("c",&seat_type);
    				printf("\n Your flight to %s is scheduled for %s %s at %.s ",dest,day,date,time);
    				printf("\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
    				break;
    			case '2':
    				dest=='Paris';
    				day=='Tuesday';
    				time=='07.00';
    				printf("\n Please select a date:");
    				scanf("%s",&date);
    				printf("\n Please select the type of seat: T for tourist and F for first class");
    				scanf("c",&seat_type);
    				printf("\n Your flight to % is scheduled for %s %s at %.s ",dest,day,date,time);
    				printf("\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
    				break;
    				
    			case '3':
    				dest=='Dubai';
    				day=='Wednesday';
    				time=='15.30';
    				printf("\n Please select a date:");
    				scanf("%s",&date);
    				printf("\n Please select the type of seat: T for tourist and F for first class");
    				scanf("c",&seat_type);
    				printf("\n Your flight to %s is scheduled for %s %s at %.s ",dest,day,date,time);
    				printf("\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
    				break;
    			case '4':
    				dest=='Rome';
    				day=='Thursday';
    				time=='12.00';
    				printf("\n Please select a date:");
    				scanf("%s",&date);
    				printf("\n Please select the type of seat: T for tourist and F for first class");
    				scanf("c",&seat_type);
    				printf("\n Your flight to %s is scheduled for %s %s at %.s ",dest,day,date,time);
    				printf("\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
    				break;
    			case '5':
    				dest=='Sydney';
    				day=='Friday';
    				time=='22.00';
    				printf("\n Please select a date:");
    				scanf("%s",&date);
    				printf("\n Please select the type of seat: T for tourist and F for first class");
    				scanf("c",&seat_type);
    				printf("\n Your flight to %s is scheduled for %s %s at %.s ",dest,day,date,time);
    				printf("\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
    				break;
    			}
    			
    			fprintf(fpt,"%d",s);
    			fprintf(fpt,"%s",dest);
    			fprintf(fpt, "%2d/",day);
    			fprintf(fpt, "%2d/",date);
    			fprintf(fpt, "%s", time);
    			fprintf(fpt, "%s",p_name);
    			fprintf(fpt, "%c",seat_type);
    			fprintf(fpt, "%d\n", p_cost);
    			fprintf(fpt, "%c", reserve);
    			fclose(fpt);
    		}
    
    			
    	}
    	
    	}


    Here is the error that i get with visual c++ 6.0 :

    Code:
    Compiling...
    test1.c
    C:\Documents and Settings\Desktop\C prog\test1.c(68) : error C2061: syntax error : identifier 'reserve'
    C:\Documents and Settings\l\Desktop\C prog\test1.c(71) : error C2181: illegal else without matching if
    C:\Documents and Settings\\Desktop\C prog\test1.c(86) : error C2015: too many characters in constant
    C:\Documents and Settings\\Desktop\C prog\test1.c(87) : error C2015: too many characters in constant
    C:\Documents and Settings\\Desktop\C prog\test1.c(88) : warning C4244: '=' : conversion from 'const double ' to 'char ', possible loss of data
    C:\Documents and Settings\Desktop\C prog\test1.c(97) : error C2015: too many characters in constant
    C:\Documents and Settings\\Desktop\C prog\test1.c(97) : warning C4553: '==' : operator has no effect; did you intend '='?
    C:\Documents and Settings\\Desktop\C prog\test1.c(98) : error C2015: too many characters in constant
    C:\Documents and Settings\\Desktop\C prog\test1.c(98) : warning C4553: '==' : operator has no effect; did you intend '='?
    C:\Documents and Settings\Desktop\C prog\test1.c(99) : error C2015: too many characters in constant
    C:\Documents and Settings\Desktop\C prog\test1.c(99) : warning C4553: '==' : operator has no effect; did you intend '='?
    C:\Documents and Settings\\Desktop\C prog\test1.c(109) : error C2015: too many characters in constant
    C:\Documents and Settings\\Desktop\C prog\test1.c(109) : warning C4553: '==' : operator has no effect; did you intend '='?
    C:\Documents and Settings\\Desktop\C prog\test1.c(110) : error C2015: too many characters in constant
    C:\Documents and Settings\Desktop\C prog\test1.c(110) : warning C4553: '==' : operator has no effect; did you intend '='?
    C:\Documents and Settings\Desktop\C prog\test1.c(111) : error C2015: too many characters in constant
    C:\Documents and Settings\\Desktop\C prog\test1.c(111) : warning C4553: '==' : operator has no effect; did you intend '='?
    C:\Documents and Settings\\Desktop\C prog\test1.c(120) : warning C4553: '==' : operator has no effect; did you intend '='?
    C:\Documents and Settings\\Desktop\C prog\test1.c(121) : error C2015: too many characters in constant
    C:\Documents and Settings\\Desktop\C prog\test1.c(121) : warning C4553: '==' : operator has no effect; did you intend '='?
    C:\Documents and Settings\Desktop\C prog\test1.c(122) : error C2015: too many characters in constant
    C:\Documents and Settings\\Desktop\C prog\test1.c(122) : warning C4553: '==' : operator has no effect; did you intend '='?
    C:\Documents and Settings\\Desktop\C prog\test1.c(131) : error C2015: too many characters in constant
    C:\Documents and Settings\\Desktop\C prog\test1.c(131) : warning C4553: '==' : operator has no effect; did you intend '='?
    C:\Documents and Settings\\Desktop\C prog\test1.c(132) : error C2015: too many characters in constant
    C:\Documents and Settings\\Desktop\C prog\test1.c(132) : warning C4553: '==' : operator has no effect; did you intend '='?
    C:\Documents and Settings\\Desktop\C prog\test1.c(133) : error C2015: too many characters in constant
    C:\Documents and Settings\\Desktop\C prog\test1.c(133) : warning C4553: '==' : operator has no effect; did you intend '='?
    Error executing cl.exe.
    
    test1.obj - 15 error(s), 13 warning(s)

    plzz helppppppppp........
    Last edited by Dark_Soul; 02-18-2008 at 11:07 AM.

  2. #2
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    For a start this wont work:
    Code:
    		if 
    			reserve =='N'
    			break;
    		
    		else
    You want something like:
    Code:
    if(reserve == 'N')
        break;
    else

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Wow. So many errors.
    I think you might need to relearn some about the language.
    For example,
    Code:
    dest=='Sydney';
    == is for comparison, = is for assign.
    '' is for a character, "" is for strings.
    And you can't simply assign strings like that. Not in C. No, no.

    I suggest you try to study a little more.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    Dark_Soul: Look up strcpy to find out how to set a string value.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  3. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM