Windows7 下emacs里开gdb的问题

[复制链接]
查看11 | 回复10 | 2021-1-27 06:45:37 | 显示全部楼层 |阅读模式


我写了个最简单的输入字符串再显示的代码。在gdb中还没输入就退出了。
但是在dos下gdb没有这个问题。
想请问是怎么回事?难道是gud的问题吗?
分 -->
回复

使用道具 举报

千问 | 2021-1-27 06:45:37 | 显示全部楼层
顶一下~~~
回复

使用道具 举报

千问 | 2021-1-27 06:45:37 | 显示全部楼层
加一句cin.clear();试试看。
回复

使用道具 举报

千问 | 2021-1-27 06:45:37 | 显示全部楼层
加了,出现了更奇怪的现象


和我的Emacs配置无关。我把配置文件移除,进gdb也是这样
回复

使用道具 举报

千问 | 2021-1-27 06:45:37 | 显示全部楼层
引用2楼zhao4zhong1的回复:加一句cin.clear();试试看。
忘了引用。。回复见上图。谢谢老师!
回复

使用道具 举报

千问 | 2021-1-27 06:45:37 | 显示全部楼层
你的getline有问题:
getline
template
basic_istream&getline(
basic_istream&is,
basic_string&str);
template
basic_istream&getline(
basic_istream&is,
basic_string&str,
Edelim);
Thefirsttemplatefunctionreturnsgetline(is,str,is.widen('\n')).
Thesecondtemplatefunctionreplacesthesequencecontrolledbystrwithasequenceofelementsextractedfromthestreamis.Inorderoftesting,extractionstops:
Atendoffile.
Afterthefunctionextractsanelementthatcomparesequaltodelim,inwhichcasetheelementisneitherputbacknorappendedtothecontrolledsequence.
Afterthefunctionextractsis.max_size()elements,inwhichcasethefunctioncallssetstate(ios_base::failbit).
Ifthefunctionextractsnoelements,itcallssetstate(failbit).Inanycase,itreturns*this.
Seetherelatedsampleprogram.

istream::getline
istream&getline(char*pch,intnCount,chardelim='\n');
istream&getline(unsignedchar*puch,intnCount,chardelim='\n');
istream&getline(signedchar*psch,intnCount,chardelim='\n');
Parameters
pch,puch,psch
Apointertoacharacterarray.
nCount
Themaximumnumberofcharacterstostore,includingtheterminatingNULL.
delim
Thedelimitercharacter(defaultstonewline).
Remarks
Extractscharactersfromthestreamuntileitherthedelimiterdelimisfound,thelimitnCount–1isreached,orendoffileisreached.Thecharactersarestoredinthespecifiedarrayfollowedbyanullterminator.Ifthedelimiterisfound,itisextractedbutnotstored.
Thegetfunction,incontrast,neitherextractsnorstoresthedelimiter.
istreamOverview|InputStreamClasses
SeeAlsoistream::get,istream::read

basic_istream::getline
basic_istream&getline(E*s,streamsizen);
basic_istream&getline(E*s,streamsizen,Edelim);
Thefirstoftheseunformattedinputfunctionsreturnsgetline(s,n,widen('\n')).
Thesecondfunctionextractsupton-1elementsandstorestheminthearraybeginningats.ItalwaysstoresE(0)afteranyextractedelementsitstores.Inorderoftesting,extractionstops:
Atendoffile.
Afterthefunctionextractsanelementthatcomparesequaltodelim,inwhichcasetheelementisneitherputbacknorappendedtothecontrolledsequence.
Afterthefunctionextractsis.max_size()elements.
Ifthefunctionextractsnoelements,itcallssetstate(failbit).Inanycase,itreturns*this.

回复

使用道具 举报

千问 | 2021-1-27 06:45:37 | 显示全部楼层
引用2楼zhao4zhong1的回复:加一句cin.clear();试试看。


我换了个更直接一点的。感觉是emacs的问题了
回复

使用道具 举报

千问 | 2021-1-27 06:45:37 | 显示全部楼层
引用2楼zhao4zhong1的回复:加一句cin.clear();试试看。
感觉是emacs下gdb的输入问题
回复

使用道具 举报

千问 | 2021-1-27 06:45:37 | 显示全部楼层



回复

使用道具 举报

千问 | 2021-1-27 06:45:37 | 显示全部楼层
istream&getline(char*pch,intnCount,chardelim='\n');
getline第2个参数是intnCount,你错用成chardelim了!
我怀疑。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行