我来我网
https://5come5.cn
 
您尚未 登录  注册 | 菠菜 | 软件站 | 音乐站 | 邮箱1 | 邮箱2 | 风格选择 | 更多 » 
 

本页主题: 调试程序时出现的问题 显示签名 | 打印 | 加为IE收藏 | 收藏主题 | 上一主题 | 下一主题

光子vs电子



性别: 帅哥 状态: 该用户目前不在线
头衔: 程序小白
等级: 人见人爱
家族: YD一族
发贴: 3379
威望: 0
浮云: 0
在线等级:
注册时间: 2007-04-29
最后登陆: 2022-12-09

5come5帮你背单词 [ gold /gəuld/ n. 金,金币,财富,金黄色;a. 金(制)的,含金的 ]


调试程序时出现的问题

这个程序是读入一个文本,然后输出该文本,并且打印文本中行的数目以及每一个字母出现的次数(不分大小写)因为刚开始用VC,提示都看不懂,求达人不吝赐教
//Program: Line and letter count
#include <iostream>
#include <fstream>
#include <cctype>
using namespace std;
void initialize(int& lc,int list[]);
void copyText(ifstream& intext,ofstream&,outtext,char& ch,int list[]);
void characterCount(char ch,int list[]);
void writeTotal(ofstream& outtext,int lc,int list[]);
int list[26];
int main()
{
    //Step 1;Declare variables
int lineCount;
int letterCount[26];
char ch;
ifstream infile;
ofstream outfile;
infile.open("e:a.txt");
if(!infile)
{
  cout<<"Cannot open  input file."<<endl;
  return 1;
}
outfile.open("e:b.txt");
initialize(lineCount,letterCount);
infile.get(ch);
while(infile)
{
    copyText(infile,outfile,ch,letterCount);
    lineCount++;
    infile.get(ch);
}
writeTotal(outfile,lineCount,ch,letterCount);
infile.close();
outfile.close();
return 0;
}
void initialize(int& lc,int list[])
{
    int j;
    lc=0;
    for(j=0;j<26;j++)
        list[j]=0;
}
void copyText(ifstream& intext,ofstream& outtext,char& ch,int list[])
{
    while(ch!='\n') //Process the entire line
    {
        outtext<<ch;//Output the character
        characterCount(ch,list);
        intext.get(ch);//Read the next character
    }outtext<<ch;//Output the newline character
}
void characterCout(char ch,int list[])
{
    int index;
    ch=toupper(ch);
    index=static_cast<int>(ch-65);//Step b
    if(0<=index&&index>=26)//Step c
        list[index]++;
}
void writeTotal(ofstream& outtext,int lc,int list[])
{
    int index;
    outtext<<endl<<endl;
    outtext<<"The number of lines="<<lc<<endl;
    for(index=0;index<26;index++)
        outtext<<static_cast<char>(index+65)<<"count="
        <<list[index]<<endl;
}
顶端 Posted: 2008-01-01 19:48 | [楼 主]
光子vs电子



性别: 帅哥 状态: 该用户目前不在线
头衔: 程序小白
等级: 人见人爱
家族: YD一族
发贴: 3379
威望: 0
浮云: 0
在线等级:
注册时间: 2007-04-29
最后登陆: 2022-12-09

5come5帮你背单词 [ architecture /'a:kitektə/ n. 建筑学,建筑式样,结构,构造 ]


------------
Compiling...
point.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\point\point.cpp(7) : error C2061: syntax error : identifier 'outtext'
C:\Program Files\Microsoft Visual Studio\MyProjects\point\point.cpp(30) : error C2660: 'copyText' : function does not take 4 parameters
C:\Program Files\Microsoft Visual Studio\MyProjects\point\point.cpp(34) : error C2660: 'writeTotal' : function does not take 4 parameters
执行 cl.exe 时出错.
顶端 Posted: 2008-01-01 19:48 | [1 楼]
光子vs电子



性别: 帅哥 状态: 该用户目前不在线
头衔: 程序小白
等级: 人见人爱
家族: YD一族
发贴: 3379
威望: 0
浮云: 0
在线等级:
注册时间: 2007-04-29
最后登陆: 2022-12-09

5come5帮你背单词 [ warm /wo:m/ a. 温暖的,暖和的,热情的,热心的,保暖的,御寒的;vt. (使)温暖 ]


Quote:
引用第2楼tuotuo25于2008-01-01 19:53发表的  :
只可惜我不是高人  我楼下的帮你解决

还是谢谢帮顶嘛
顶端 Posted: 2008-01-01 19:54 | [2 楼]
光子vs电子



性别: 帅哥 状态: 该用户目前不在线
头衔: 程序小白
等级: 人见人爱
家族: YD一族
发贴: 3379
威望: 0
浮云: 0
在线等级:
注册时间: 2007-04-29
最后登陆: 2022-12-09

5come5帮你背单词 [ fifty /'fifti/ num. 五十 ]


Quote:
引用第4楼sitademail于2008-01-01 19:59发表的  :

不会cpp,cpp里面取地址符号和变量类型可以连起写吗?char&

可以的撒。
顶端 Posted: 2008-01-01 20:02 | [3 楼]
光子vs电子



性别: 帅哥 状态: 该用户目前不在线
头衔: 程序小白
等级: 人见人爱
家族: YD一族
发贴: 3379
威望: 0
浮云: 0
在线等级:
注册时间: 2007-04-29
最后登陆: 2022-12-09

5come5帮你背单词 [ product /'prodəkt/ n. 产品,制品,结果,成果,乘积 ]


人呢
顶端 Posted: 2008-01-01 20:03 | [4 楼]
光子vs电子



性别: 帅哥 状态: 该用户目前不在线
头衔: 程序小白
等级: 人见人爱
家族: YD一族
发贴: 3379
威望: 0
浮云: 0
在线等级:
注册时间: 2007-04-29
最后登陆: 2022-12-09

5come5帮你背单词 [ respectful /ris'pektful/ a. 恭敬的,有礼貌的 ]


Quote:
引用第7楼sitademail于2008-01-01 20:06发表的  :

这个提示该看得懂了吧,我用vs测试的
[attachment=1400880]

中文还是认识的谢谢
顶端 Posted: 2008-01-01 20:07 | [5 楼]
光子vs电子



性别: 帅哥 状态: 该用户目前不在线
头衔: 程序小白
等级: 人见人爱
家族: YD一族
发贴: 3379
威望: 0
浮云: 0
在线等级:
注册时间: 2007-04-29
最后登陆: 2022-12-09

5come5帮你背单词 [ hope /həup/ n. 希望,期望,所希望的人或事;n. 希望,期望 ]


Linking...
point.obj : error LNK2001: unresolved external symbol "void __cdecl characterCount(char,int * const)" (?characterCount@@YAXDQAH@Z)
Debug/point.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.

point.exe - 1 error(s), 0 warning(s)
这个有有是嘛意思
顶端 Posted: 2008-01-01 20:13 | [6 楼]
我来我网·5come5 Forum » 程序员之家

Total 0.009957(s) query 6, Time now is:09-19 07:08, Gzip enabled
Powered by PHPWind v5.3, Localized by 5come5 Tech Team, 黔ICP备16009856号