[ create a new paste ] login | about

Link: http://codepad.org/c1rAAFnp    [ raw code | output | fork ]

C++, pasted on Jul 19:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
typedef struct node{
   char name[400];
   struct node *next;
 }ORDER;

void order_list(ORDER *node){
   int k = 0;
   while(1){
     printf("%d番目>> ( %s )\n", k++, node->name);
	 if(node->next == NULL){
		 break;
	 }
     node = node->next;
   }
   printf("\n");
 }

void del_order_by_name(ORDER *node, char *n){
	int i;

	while(node->next != NULL){
		node=node->next;
		if(strcmp(node,n)==0){		
			node->next=node->next->next;
		}
	}	
}
 
int main(){
	int i=0;
	char *p=(char *)malloc(10*sizeof(char));
	ORDER *node=NULL,*node_k;
	char *list_name[8] = {"ueda", "kimura", "sugimoto","morita","tanaka", "komori", "tanaka", "kimura"};

	scanf("%s",p);

	 for(i=0;i<8;i++){			
		if(node==NULL){
			node = (ORDER *)malloc(sizeof(ORDER));
			node_k = node;
		}else{
			node_k ->next = (ORDER *)malloc(sizeof(ORDER));
			node_k = node_k->next;
		}
		strcpy(node_k->name, list_name[i]); 

		node_k->next = NULL;
	 }	 
	 order_list(node);

	 del_order_by_name(node,p);

	 order_list(node);	
 }


Output:
1
2
3
In function 'void del_order_by_name(ORDER*, char*)':
Line 27: error: cannot convert 'ORDER*' to 'const char*' for argument '1' to 'int strcmp(const char*, const char*)'
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: