首页 > 其他分享 >字符串-00003-堆上字符串-测试代码

字符串-00003-堆上字符串-测试代码

时间:2022-12-04 00:22:05浏览次数:72  
标签:xxx psub 测试代码 pstr2 00003 printf 字符串 output pstr1

  • main.c
  • 头文件请参考:https://www.cnblogs.com/kxwslmsps/p/16949213.html
  • 实现文件 myString.c请参考:https://www.cnblogs.com/kxwslmsps/p/16949223.html
  • #include"myString.h"
    
    void test01()
    {
    	char* str2 = "123456789abcdefghijklmn";
    
    	myString pstr;
    	myString pstr1;
    	myString pstr2;
    	myString psub;
    
    	xxx_init(&pstr);
    	xxx_init(&pstr1);
    	xxx_init(&pstr2);
    	xxx_init(&psub);
    
    	printf("\n=====assign============================================\n");
    	xxx_assign(&pstr2, str2);
    	xxx_output(&pstr2);
    
    	printf("\n=====copy=============================================\n");
    	xxx_copy(&pstr1, &pstr2);
    	printf("pstr1:");
    	xxx_output(&pstr1);
    	printf("pstr2:");
    	xxx_output(&pstr2);
    
    	printf("\n=====subStr==========================================\n");
    	
    	xxx_subStr(&pstr1, &psub, 2, 5);
    	printf("pstr1:");
    	xxx_output(&pstr1);
    	printf("psub:");
    	xxx_output(&psub);
    
    	printf("\n=====remove==========================================\n");
    	xxx_remove(&pstr1, 2, 5);
    	printf("pstr1:");
    	xxx_output(&pstr1);
    	printf("psub:");
    	xxx_output(&psub);
    
    	printf("\n =====insert=========================================\n");
    	xxx_insert(&pstr1, &psub, 2);
    	printf("pstr1:");
    	xxx_output(&pstr1);
    	printf("psub:");
    	xxx_output(&psub);
    
    	printf("\n =====concat=========================================\n");
    	xxx_concat(&pstr, &pstr1, &pstr2);
    	printf("pstr1:");
    	xxx_output(&pstr1);
    	printf("pstr2:");
    	xxx_output(&pstr2);
    	printf("pstr:");
    	xxx_output(&pstr);
    
    	printf("\n =====compare=======================================\n");
    	printf("pstr1:");
    	xxx_output(&pstr1);
    	printf("pstr2:");
    	xxx_output(&pstr2);
    	printf("pstr:");
    	xxx_output(&pstr);
    
    
    	int ret = xxx_compare(&pstr, &pstr2);
    	printf("comapre=%d\n", ret);
    	
    
    	xxx_destroy(&pstr);
    	xxx_destroy(&pstr1);
    	xxx_destroy(&pstr2);
    	xxx_destroy(&psub);
    
    
    }
    
    int main()
    {
    	test01();
    	system("pause");
    	return 0;
    }
    

      

标签:xxx,psub,测试代码,pstr2,00003,printf,字符串,output,pstr1
From: https://www.cnblogs.com/kxwslmsps/p/16949235.html

相关文章