![]() |
| ||
| can someone please explain??????? can someone please explain to me 1) the difference between getline and gets(). 2) why sometimes when getline is used along with some other cin statements it skips some of the cin statements. :sad: 3)what exactly does the array of structures do? please help me out with this. |
| ||
| Re: can someone please explain??????? The getline function is used to read another line of input. Not only can getline read from the regular input data stream, it can also handle input from files and pipes. The getline function is similar to awk's next statement. While both cause the next input line to be read, the next statement passes control back to the top of the script. The getline function gets the next line without changing control in the script. Possible return values are: 1If it was able to read a line. 0If it encounters the end-of-file. -1If it encounters an error. NOTE: Although getline is called a function and it does return a value, its syntax resembles a statement. Do not write getline(); its syntax does not permit parentheses.In the previous chapter, we used a manual page source file as an example. The -man macros typically place the text argument on the next line. Although the macro is the pattern that you use to find the line, it is actually the next line that you process. For instance, to extract the name of the command from the manpage, the following example matches the heading "Name," reads the next line, and prints the first field of it: I hope this helps. Sorry if it didnt, but I tried LOL1:o |
| ||
| Re: can someone please explain??????? >1) the difference between getline and gets(). gets is a throwback from ancient C, is impossible to use safely, and should never be used in C++. getline is okay because you can supply a limit for how many characters to read. >2) why sometimes when getline is used along with some other cin >statements it skips some of the cin statements cin will leave a newline character in the stream, and getline uses a newline character as the default termination sentinel. The result is that getline appears to be skipped. If that's not your problem then give us an example with code. >3)what exactly does the array of structures do? What array of structures? Your question is incomplete. |
| ||
| Re: can someone please explain??????? Thanks guys |
| All times are GMT -4. The time now is 12:04 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC