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;
			}

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')

is there any other way to do it im using gcc to compile and i can not use getc

getch* is getchar the same ?

i used getchar im still stuck in the loop i cant break out of it ???

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);
}

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

no worries i got it to work thanks for the help i used scanf instead

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.