0

i cant break out of this loop its driving me crazzy!!

while (1)
	{	
	
	printf("please type in the path for the file you want to archive\n");
	scanf("%s",&original_file);
	open_pointer = fopen( original_file, "rb");								 
	original_pointer = fopen(original_file,"rb");							
	copy_pointer = fopen( archive_name,"ab");
	
	if (copy_pointer  NULL)
	{
		printf("\n copied successfull");
		puts("\nenter  x to coninue");
   
	if   ((answer = getc(stdin)) == 'x')
		
		break;
		else
		continue;
			}
2
Contributors
7
Replies
9
Views
7 Years
Discussion Span
Last Post by moroccanplaya
0

May be getc() wont return unless enter hit so use getch() which returns key pressed and neither echo it to the screen..

if   ((answer = getch()) == 'x')

Edited by Shankye: n/a

0

getch() completely worked fine for me ..

Here is code which compiled and worked for me ..

#include <stdio.h>

int main (void)
{

  char temp;
  while(1)
  {
     if( (temp=getch()) == 'x')
     {
        printf("Bye");
        exit(0);
     }
     printf("Looping");
   }
 return(0);
}
1

Write to fflush all the buffers and make stdin and stdout clean..

IF possible post full code, will try to compile and check whether it works here

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.