高分求教!(简单问题)

fanlongly 2003-10-15 02:03:44
现有文本文件,其内容如下:我想顺序得到每个单引号内的数据。请给出源代码,不胜感激!

GEN13.0
'225','GB0005.VAL|<>G_80',10','c','d','e','f',,'p','q','r','d','t','u',''
'202','80','1','1','abc','','GB 93-87','','垫圈'
'265','GB009.VAL|<>G_80',10','c','d','m','f',,'p','o','r','s','t','u',''
'209','8000','1','1','ajc','','GB 93-87','','垫圈'
...全文
38 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
gaoxiaopai 2003-10-16
  • 打赏
  • 举报
回复
信箱
hardstudylulin 2003-10-15
  • 打赏
  • 举报
回复
for(int j=0;j<nLength;j++){//main circle begin
CString strTemp=strText.Mid(j,1);
if(strTemp==";"){
CString strSelect;
strSelect=strText.Left(j);
int nSelectLength=strSelect.GetLength ();
for( k=nSelectLength-1;k>=0;k--){//get data begin
CString strTempSel=strSelect.GetAt (k);
CString strTempTwoCheck=strSelect.GetAt (k-1);
if(strTempSel==" "&&strTempTwoCheck==":"){
if(strCheckSel=="Beam") {
strInsertData=strSelect.Mid(k+1,nSelectLength-1);
ParameterArray.Add (strInsertData);
}
if(strCheckSel=="Accuracy(%)"){
strInsertData=strSelect.Mid(k+1,nSelectLength-1);
ListDataArray.Add (strInsertData);
}
break;
}
}//end get data
}//end if
}//end main circle
hardstudylulin 2003-10-15
  • 打赏
  • 举报
回复
告诉你思路:
利用函数:ReverseFind()可以找到最后一个‘,
用循环取出’前的字符,存入一个数组中,再删除这部分,字符没有了,就取完了。
mathliu 2003-10-15
  • 打赏
  • 举报
回复
//Find all substrings and add them to a listbox
void SplitStr(CString& s)
{
int nFirst=0;
int nLast=-1;
while(TRUE)
{
nFirst=s.Find("'",nLast+1);
if(nFirst==-1)
break;
nLast=s.Find("'",nFirst+1);
CString strTmp;
m_list.AddString(s.Mid(nFirst+1,nLast-nFirst-1));
}
}
阿甘 2003-10-15
  • 打赏
  • 举报
回复
'225','GB0005.VAL|<>G_80',10','c','d','e','f',,'p','q','r','d','t','u',''
~~~~~~~~
这里的引号不对吧。。。
zhangnanonnet 2003-10-15
  • 打赏
  • 举报
回复
FILE *openfile;
int count;
char buf[2];
BOOL bSingle;
CString strTmp;

bSingle = TRUE;
memset(buf, 0, 2);

if ((openfile = fopen("tmp.txt", "rt")) != NULL)
{
count = fread(buf, sizeof(char), 1, openfile);
while(!feof(openfile))
{
if (memcmp(buf, "'", 1) == 0)
{
if (bSingle)
{
strTmp = "";
bSingle = FALSE;
}
else
{
AfxMessageBox(strTmp);
bSingle = TRUE;
}
}
else
{
if (!bSingle)
{
strTmp += buf;
}
}
count = fread(buf, sizeof(char), 1, openfile);
}
fclose(openfile);
}
Pipi0714 2003-10-15
  • 打赏
  • 举报
回复
读出来放到一个数组中去然后循环判断字符是否是\'是去掉否则继续循环

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧