switch case and fopen together

This is a discussion on switch case and fopen together within the C Programming forums, part of the General Programming Boards category; HI , In my program i have got switch case, in one of the cases i want that the C ...

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    14

    switch case and fopen together

    HI ,

    In my program i have got switch case, in one of the cases i want that the C program shd get executed ?

    Is there any possibility that the same can be done .

    In my code the below after execution of the case 1:

    i am able to see the source code and not the program

    Code:
    	{
    	    case 1:
    			clrscr();
    			fp1=fopen("c:\\three15.c","rb");
    				while(1)
    				  if (ch1==EOF)
    				    break;
    				else
    				{
    				   ch1=fgetc(fp1);
    				   printf("%c",ch1);
    				}
    			 getch();
    			 fclose(fp1);
    			break;
    
    
    	{
    pls help

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,751
    1. use functions to simplify the code, as in
    case 1: doReadFile(); break;

    2. Use lots of braces to make your code more explicit. Your while(1) loop especially needs some braces.

    3. Use consistent indentation to help you (and others) work out what is going on.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 02:01 AM
  3. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 02:04 PM
  4. Segmentation Fault
    By blaksheep423 in forum C Programming
    Replies: 11
    Last Post: 12-07-2006, 05:28 AM
  5. File I/O
    By bliss in forum C++ Programming
    Replies: 11
    Last Post: 06-30-2005, 04:38 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21