char punct(char a[], int len) {
for (int i = 0; i < len; i++) {
if (ispunct(a[i]))
{ return i; }
return -1;
}
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我为什么这个函数只为我交给它的每个字符串返回-1?我正在编写一个程序来从.txt文件中取出单词并将它们(稍加改动)输出到另一个.txt文件中,我需要从字符串中删除标点符号.但是,我似乎无法检测标点符号使用ispunct()函数的位置.我甚至使用我能想象到的所有标点符号来编写自己的函数,它仍然只返回-1.这是函数的问题还是我给它的字符串?如果需要显示更多我的代码,请告诉我.谢谢!
1>Main.obj : error LNK2019: unresolved external symbol "void __cdecl createVideoList(class std::basic_ifstream<char,struct std::char_traits<char> > &,class Video &)" (?createVideoList@@YAXAAV?$basic_ifstream@DU?$char_traits@D@std@@@std@@AAVVideo@@@Z) referenced in function _main
1>c:\users\******\documents\visual studio 2010\Projects\Programming Assignment 4\Debug\Programming Assignment 4.exe : fatal error LNK1120: 1 unresolved externals
Run Code Online (Sandbox Code Playgroud)
我正在编写一个编程作业,我在尝试编译时遇到了这个链接错误2019.它引用了createVideoList,这些是与我相关的代码行:
#include <iostream>
#include <fstream>
#include <string>
#include "Video.h"
using namespace std;
void createVideoList(ifstream& infile, Video videoArray);
int main()
{
...
createVideoList(inputfile, videoArray[50]);
}
void createVideoList(ifstream& ifile, Video videoArray[50])
{
string title;
string star1;
string star2;
string producer;
string director;
string productionCo;
int inStock;
int …Run Code Online (Sandbox Code Playgroud)