Thread: how to stop this proccess prematurely..

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Banned
    Join Date
    Oct 2008
    Posts
    1,535

    how to stop this proccess prematurely..

    i need to enter numbers in a row
    of certain length.
    if i deside size =3
    then i have to input 3 2 7
    if i press enter in the middle of the proccess it doesnt stop'
    it just enters a new line and continues from there
    i want it to sent an error instead.
    so if i will press 3 2 enter
    it will return an error
    i tried to do it here // in the commented line "\n line"
    its now working??

    Code:
    #include <stdio.h>
    int read_array(int input[],int i,int size);
     
    int main()
    {
    	int i;
        int input[40];
        printf("%d\n",read_array(input,0,8));
      for(i=0;i<8;i++)
      {
        printf("%d ",input[i]);  
      }
       printf("\n");
    }
    int read_array(int input[],int i,int size)
    {
    	int flag,rt;
           
    	if (i==size)
    	{
         
    	   return 1;
    	}
         flag=scanf("%d",&input[i]);  "\n line"
    	 if (input[i]=='\n')
    	 {
            return 0;
    	 }
    	 if (flag==0)
    	 {
    		 return 0;
    	 }
    	 else
    	 {
    	 }
         rt=read_array(input,i+1,size); 
    	 return rt;
    }
    Last edited by transgalactic2; 01-28-2009 at 07:52 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fscanf %s or %d integer input space char stop question...
    By transgalactic2 in forum C Programming
    Replies: 5
    Last Post: 04-14-2009, 10:44 AM
  2. Error stop Http Listener
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 06-04-2008, 02:14 AM
  3. when a while loop will stop ?
    By blue_gene in forum C Programming
    Replies: 13
    Last Post: 04-20-2004, 03:45 PM
  4. Proccess and Thread ?
    By Devil Panther in forum Windows Programming
    Replies: 9
    Last Post: 11-17-2003, 12:59 PM
  5. Telling other applications to stop
    By nickname_changed in forum Windows Programming
    Replies: 11
    Last Post: 09-25-2003, 12:47 AM