⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_38086.htm

📁 一些关于vc的问答
💻 HTM
字号:
<p>
序号:38086 发表者:maginn 发表日期:2003-04-30 16:25:57
<br>主题:我的结构定义那里错了??
<br>内容:struct tegStudent<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;int nCode;<BR>&nbsp;&nbsp;&nbsp;&nbsp;char sName[10];<BR>&nbsp;&nbsp;&nbsp;&nbsp;int nAge;<BR>}STUDENT;<BR>bool mydialog::Copy2(CString strSource, CString strTarget)<BR>{<BR>CFile fSource;<BR>CFile fTarget;<BR>STUDENT s;&nbsp;&nbsp;<BR><BR>/*错现错误如下D:\my program\c\opendialg\mydialog.cpp(129) : error&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;C2146: syntax error : missing ';' before identifier 's'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;D:\my program\c\opendialg\mydialog.cpp(129) : errorC2065: 's' :&nbsp;&nbsp; undeclared identifier<BR>*/<BR> int nCount;<BR> if (!fSource.Open(strSource,CFile::modeRead))<BR> {<BR>&nbsp;&nbsp;&nbsp;&nbsp; MessageBox("con't open file");<BR>&nbsp;&nbsp;&nbsp;&nbsp; return false;<BR> }<BR> if (!fTarget.Open(strTarget,CFile::modeCreate|CFile::modeWrite))<BR> {<BR>&nbsp;&nbsp;&nbsp;&nbsp; MessageBox("create target file fail");<BR>&nbsp;&nbsp;&nbsp;&nbsp; fSource.Close();<BR>&nbsp;&nbsp;&nbsp;&nbsp; return false;<BR> }<BR> nCount=fSource.Read(s,sizeof(STUDENT));&nbsp;&nbsp;//读文件<BR> while (nCount)<BR> {<BR>&nbsp;&nbsp;&nbsp;&nbsp; fTarget.Write(s,sizeof(STUDENT));//写文件<BR>&nbsp;&nbsp;&nbsp;&nbsp; nCount=fSource.Read(s,sizeof(STUDENT)); //?请问这句话有什么用阿??<BR> }<BR> fSource.Close();<BR> fTarget.Close();<BR><BR><BR>} 
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:张志民 回复日期:2003-04-30 17:52:48
<br>内容:struct tegStudent<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;int nCode;<BR>&nbsp;&nbsp;&nbsp;&nbsp;char sName[10];<BR>&nbsp;&nbsp;&nbsp;&nbsp;int nAge;<BR>}STUDENT;<BR>在这里 STUDENT只是struct tegStudent结构定义的一个变量,相当于<BR>struct tegStudent STUDENT;就像是int i, i是int类型的一个变量;<BR>STUDENT并不是结构体名称。<BR><BR>你要想使用STUDENT s;&nbsp;&nbsp;可以这样:<BR>typedef struct tegStudent STUDENT;<BR>STUDENT s;
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:maginn 回复日期:2003-04-30 19:32:37
<br>内容:请问结构中<BR>class kkk{<BR>public<BR>int a;<BR>int b;<BR>}<BR>这样的结构和struct有什么区别阿?<BR><BR>还有<BR>typedef struct tegStudent STUDENT;<BR>STUDENT s;<BR>这句话直接写道函数中间就可以吗?<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:DVC 回复日期:2003-04-30 20:22:52
<br>内容:定义一个CSTRING 然后在其字符的末端加"\r\n"就好了! 
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:moli 回复日期:2003-04-30 20:47:28
<br>内容:建议你找一本c++看看。typedef struct mystructtag<BR>{<BR>&nbsp;&nbsp; int&nbsp;&nbsp; i;<BR>&nbsp;&nbsp; float f;<BR>&nbsp;&nbsp; char&nbsp;&nbsp;c;<BR>} mystruct;<BR><BR>mystruct ms;&nbsp;&nbsp; // Equivalent to "struct mystructtag ms;"<BR><BR>typedef int (*funcptr)();&nbsp;&nbsp;// funcptr is synonym for "pointer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;to function returning int"<BR><BR>funcptr table[10];&nbsp;&nbsp; // Equivalent to "int (*table[10])();"<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -