Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

哪位大哥帮我看一下问题出在哪? runtime error 折磨我啊

Posted by xgl at 2010-05-04 13:47:41 on Problem 1028
#include <stdio.h>
#include <string.h>
#include <malloc.h>

void main ()
{
   char *back[10], *forward[10], *p, *q;
   int  i = -1, j = -1; 
   q = (char*)malloc (50*sizeof(char));
   q = "http://www.acm.org/";
   p = (char*)malloc (10*sizeof(char)); 
   scanf("%s",p);
  
   while (strcmp(p, "QUIT") != 0)
   {
	  
	   if(strcmp (p , "VISIT") == 0)
	   {
		   
		   back[++i] = q;
	       q = (char*)malloc (50*sizeof(char));
		   scanf("%s",q); 
		   puts(q);
		   j = -1;
	   }
	  if (strcmp (p, "BACK") == 0)
	        if (i > -1)
			    {
				 forward[++j] =  q;
				  q = back[i--];
				puts(q);
			  }
             else
				 printf ("Ignored\n");
			 
	  if (strcmp(p, "FORWARD") == 0 )
		     if (j > -1)
			 {
			   back[++i] = q;
			   q = forward[j--];
			   puts(q);
			 } 
		     else 
				 printf ("Ignored\n");
		     
		   memset(p, 0, 10);
	       scanf("%s",p);
   }

   
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator