注册 登录
编程论坛 C++教室

下午刚学,没有书本,问下这段程序怎么写才对?

H 发布于 2009-12-27 19:45, 686 次点击
下午看了朋友的课件

#include "stdio.h"
#include "iostream.h"


void main()
{
        write1("hehe");
}
void write1(string s)
{
    cout<<s;
}

可这段程序怎么调试都不成功!
请问要怎么修改?
6 回复
#2
英英2009-12-27 20:06
#include "iostream.h"
void write1(char s[]);

void main()
{   
    write1("hehe");
}
void write1(char s[])
{
    cout<<s;
}
#3
forclwy2009-12-27 20:14
#include "stdio.h"
#include "iostream.h"
#include <string>//要用String要包含头文件
void write1(string s)
{
    cout<<s;
}
void main()
{
        write1("hehe");//使用函数之前要么声明,要么定义在前面
}
#4
yangliangbin2009-12-27 20:54

#include<iostream>
#include<string>
using namespace std;
void main()
{
    void write1(string);声明函数
    write1("hehe");
}
void write1(string s)
{
    cout<<s<<endl;
}
#5
H2009-12-27 21:27
2楼,4楼调试成功,3楼错误。



谢谢数组那位和另外两外热心人

[ 本帖最后由 H 于 2009-12-27 21:29 编辑 ]
#6
zhoufeng19882009-12-27 23:56
好!
#7
dancing1wolv2009-12-28 14:02
以下是引用forclwy在2009-12-27 20:14:04的发言:

#include "stdio.h"
#include "iostream.h"
#include //要用String要包含头文件
void write1(string s)
{
    cout<
把void write1(string s)改为void writel(char *s)也可以吧
1