注册 登录
编程论坛 VC++/MFC

学用string字符串,将随机输入的各个数字位用字符隔开构成字符串,函数参数为整数及字符,返回结果为字符串。

KANCY 发布于 2013-03-08 18:14, 545 次点击
#include "stdafx.h"
#include<iostream>
#include<string>
using namespace std;

char* fun(int&p,char *m)
{
    string s=NULL;
    while (p!=0)
    {   
        s+=p%10;
        p/=10;
        if (p!=0)
            s+=*m;
    }
    return s;
}
int main(int argc, char* argv[])
{
    string st;
    cout<<"Enter number:"<<endl;
    int i;
    cin>>i;
    st=fun(i,c);
    cout<<"st"<<endl;
    return 0;
}
5 回复
#2
KANCY2013-03-08 18:14
请问哪里有问题啊
#3
Susake2013-03-08 18:16
#include "stdafx.h"
没有这个头文件吧
#4
KANCY2013-03-08 18:18
回复 3楼 Susake
系统上带的啊
#5
KANCY2013-03-08 18:31
请问 哪里哪里  出现问题啊
#6
bczgvip2013-03-17 16:12
st=fun(i,c); // c 是什么?
1