标题:请各位帅哥美女帮忙看下程序哪有问题?
取消只看楼主
daring_star
Rank: 2
等 级:论坛游民
帖 子:38
专家分:65
注 册:2013-10-20
结帖率:100%
 问题点数:0 回复次数:0 
请各位帅哥美女帮忙看下程序哪有问题?
我想用指针来复制字符串,就是把pstr1中的值复制到pstr2中,可为什么我运行程序后pstr2输出结果是空的?求指点。
#include <stdio.h>
#include <stdlib.h>
void main()
{
    char *pstr1,*pstr2;

    pstr1 = (char *)malloc(100);
    pstr2 = (char *)malloc(100);
   
    printf("请输入需要复制的字符串\n");

    gets(pstr1);

    while(1)
    {
        if(*pstr1 == '\0')
            break;
        *(pstr2++) = *(pstr1++);
    }
    *pstr2 = '\0';
    printf("%s\n",pstr2);
}
搜索更多相关主题的帖子: 帅哥美女 运行程序 include 字符串 
2013-12-03 16:32



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-424638-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.278571 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved