http:^^www.cs.wisc.edu^~cs302^faq.html
来自「This data set contains WWW-pages collect」· HTML 代码 · 共 530 行 · 第 1/2 页
HTML
530 行
the "cin.getline" that really takes input. Here's an example that suffersfrom this error: <br><pre> cin >> GolfScore; cin.getline( PlayerName, MAX_STR, '\n' );</pre>In this case the PlayerName would just get the null string because of thenewline character left in the input buffer by the "cin >>". Here are thetwo ways to problem can be fixed.<pre> cin >> GolfScore; cin.ignore( MAX_STR, '\n' ); cin.getline( PlayerName, MAX_STR, '\n' );</pre>or<pre> cin >> GolfScore; cin.getline( dummy_buffer, MAX_STR, '\n' ); cin.getline( PlayerName, MAX_STR, '\n' );</pre></li><LI><STRONG>My program runs correctly and now I am redirecting the output to a file. When I ran the program the first time, it worked great, but now when I run it I get the same output as the first time, no matter how I change the input. What's the problem?</STRONG><BR><BR>Chance are that you still have the output file open from the first time youran the program. Windows basically will lock files that are in open windowsso that you cannot overwrite the contents of the file. To remedy this, justclose the output file after you have printed it. To find out if you do havethe output file open, choose the Window menu. It will tell you exactly whatyou have open.<BR><BR></LI><LI><STRONG>When I run my program and redirect the output to a file, the outputfile is always empty. Why?</STRONG><BR><BR>If you are also redirecting the input, you want to check to make sure thatyou have the path name to the file typed in correctly. If you have the pathname hard coded in your program, you want to make sure that you have used twobackslashes "\" for every one in your path. For example, the following filer:\public\jjason\myfile.in would be coded as follows in your program:<PRE>ifstream input("r:\\public\\jjason\\myfile.in");</PRE>Also, make sure that if you copied the input file from an instructor, that youcopied to the correct directory.<BR><BR></LI><li> <strong> I'm trying to output with "cout", but a get a compiler error tellingme, "Illegal structure operation." </strong> <br> <br><b>cout</b> is used to print strings and numbers and such, but if you want to printout some more complex object, you must use other means. For instance, ifyou have defined a class <b>foo</b>, you may have given it an output methodwith prints some of its internal variables or other messages: <br><pre>class foo { ... public: void Output(); ...};</pre>When you want to print out such an object, students sometimes make the mistakeof making the call to the Output member part of a cout: <br><pre> foo FooA; cout << "The object is " << FooA.Output() << ". Cool, eh?" << endl;</pre>The Output function works on its own, and should not be a part of a cout.Despite the odd notation, "cout <<" is a function call, and the function isonly able to print out numbers, strings, and characters. The correct wayto achieve the intention above is:<pre> cout << "The object is "; FooA.Output(); cout << ". Cool, eh?" << endl;</pre></li></ul><a name="Frustration"><h2> It's Just Not Working!! </h2><ul>If you're really having difficulties, remember that there are consultantsin the lab to help you most hours of the day. They keep a "consultant" signon top of the computer at which they are working and wear nametags, so theyare easy to spot. <p><LI><STRONG>My program doesn't give me the results I had hoped for. Or, my program runs, but it does some really strange things. Help!</STRONG><BR><BR>Your best bet is to run the interactive debugger. Consultants are also ableto help you, but chances are they will run the debugger themselves. Sinceyou are the one most familiar with your program, you would be the one mostlikely to spot errors quickly using the debugger. I recommend learning thebasic features of the debugger - stepping through a program and viewing thecontents of variables.<BR><BR></LI></ul><HR><A NAME="FORTRAN"><H2 ALIGN=CENTER>FORTRAN</H2><UL><LI><STRONG>A little suggestion to make you more productive</STRONG><BR><BR>When going through the program development cycle, it helps immensely if youhave two windows open with the MS-DOS prompt. In one window, you can use the editor to work on your program. The other one you can leave at the DOS promptso that you can compile and run the program. This alleviates the need toexit the editor every time you want to compile your program. <STRONG>Note:make sure that you save your program in the editor before attempting to compileit in the other window.</STRONG><BR><BR></LI></UL><HR><A NAME="MISC"><H2 ALIGN=CENTER>Miscellaneous</H2><UL><LI><STRONG>I have run out of disk space. How do I get more?</STRONG><BR><BR>You will want to use the File Manager to delete files from your user directory(drive U:\). First of all, don't delete the files that start with the letters "bc" as these are used by the Borland C++ compiler. Likely candidates are files with the following extensions: ".exe", ".obj", ".csm" and ".bak". These files are easy to reproduce. <STRONG>A word of warning, only get rid of files that you know you created (or were created on your behalf, for instance bycompiling your program).</STRONG> If you are not sure what you can delete, aska consultant.<BR><BR></LI><LI><STRONG>I have been "locked out" of my account. How do I gain access?</STRONG><BR><BR>If you type your login password wrong enough times, you will be locked out ofthe network for around 15 minutes. You will have to wait until that time hasexpired before you can log in again.<BR><BR></LI><LI><STRONG>I get a message that I have "exceeded maximum logins" and I amrefused access. How can I log in?</STRONG><BR><BR>This is caused by you being logged in to more than one computer. Make surethat you are not logged into any other machines...this includes machines inother places in which you have logged into the Computer Science network. Also,if you were working on a machine that crashed, and you immediately attemptedto log into another computer, you need to log into the machine that crashedand log out before you can log into another machine.<BR><BR></LI><LI><STRONG>I have been "locked out" of my email. How do I gain access?</STRONG><BR><BR>(From D. Parter) If you type your email password wrong enough times, kerberos locks the entry. You should go to the systems lab (2350 CS&ST) to get itunlocked.<BR><BR></LI><LI><STRONG>There are no free computers in the 1370 lab. Are there others wecan use? </STRONG><BR><BR>Try the computers in the DoIT lab in the basement of the Computer Sciencesbuilding. There should be information outside of the 1370 lab on how to getto the DoIT lab.<BR><BR></LI><LI><STRONG>I send a job to the printer, but it never prints out. What iswrong?</STRONG><BR><BR>There are two likely causes of this. The first is that the print server is notworking. The second is that you have exceeded your printer quota. Whateverthe problem, don't continue sending your files to the printer until you knowthe cause of the problem. Use the Check Print Queues program in theAdministration group to view. Run this program and make sure all the laserprinters are selected (the box next to the printer names should have an 'X';if not, click in the box and one will appear). Clicking the "check queues"button will show you a list of all the printers, and the documents waitingto be printed on each. You can spot your print jobs because they are labelledwith your username. If the queue are exceedingly long and not moving, informa consultant or the UNIX TA in 1359; there may be a problem with the printers.The Check Print Queues program also allows you to check your paper quota byclicking on the "check quota" button. If you have already printed as many pages as you are allowed, you must go to the Computer Systems Lab in2350, and pay for more paper to be credited to your account.<BR><BR></LI><LI><STRONG>I would like to forward my CS e-mail to my student e-mail account.Is that possible?</STRONG><BR><BR>Of course. You will want to use the User Util program mentioned above. Afteryou log in (using your login ID and your e-mail password), from the menu youcan select to forward your e-mail. Just follow the directions...of coursethis assumes that you have memorized your student e-mail address. You can alsouse this program to stop any forwarding of e-mail.<BR><BR></LI><LI><STRONG>I have forwarded my e-mail and I would like to be able to checkit from the 1370 lab. Is that possible?</STRONG><BR><BR>What you need to do is go into the e-mail program (Eudora). Select the Specialmenu and from there, select the Configuration option. In the box labeled POPAccount, type in the e-mail account which you would like to check. This nextpart is <STRONG>VERY</STRONG> important. Again select the Special menu andthis time select the Switches option. Make sure that the box marked "LeaveMail on Server" has an "X" in it. If you don't have this box selected, whenyou check your e-mail from the 1370 lab, it will download all of the mail inthe mailbox to your user directory. This means that you will not be able tocheck that e-mail from anywhere else. Trust me...I learned this one the hardway.<BR><BR></LI></uL><HR><EM>Last Modified February 12, 1996<BR><!WA9><A HREF="http://www.cs.wisc.edu/~perkinst/">Ted Perkins</A> / perkinst@cs.wisc.edu</BODY></HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?