![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#21 | |
|
Newbie
Join Date: Nov 2005
Posts: 23
Rep Power: 0
![]() |
Quote:
I'm not really even thinking about a career in this field. This is more of a hobby than anything else.
__________________
Magius Avvail Genocidal Studios™ Administrator Pasadena, Texas 77502 Compiler: Turbo C++ Compiler: (sometimes) Dev/Borland C++ Programmer Status: Somewhat of a Newb. |
|
|
|
|
|
|
#22 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Then piss-poor practices won't hurt you at all. Unless they spread to other areas, of course.
![]()
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#23 |
|
Hobbyist Programmer
|
getline (cin,mystring);
__________________
Hoes telling me to calm down but I'm like fuck that shit!
|
|
|
|
|
|
#24 |
|
Expert Programmer
|
i was told not to recommend that lol.. nothing from the conio library!
__________________
"When in Rome, Do as the Romans Do" "Beauty is in the eye of the BEER holder" "Save your breath your going to need it for your blow up doll later" SearchLores.org |
|
|
|
|
|
#25 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
"getline" isn't from the conio library....
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#26 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Is that specific getline from iostream or string?
|
|
|
|
|
|
#27 |
|
Hobbyist Programmer
|
according to my calculation its from....iostream
__________________
Hoes telling me to calm down but I'm like fuck that shit!
|
|
|
|
|
|
#28 |
|
The Oblivious One
Join Date: May 2005
Location: Ontario, Canada
Posts: 630
Rep Power: 4
![]() |
Just to summarize information in this thread (:p):
std::cin stops reading the input stream when a space, or newline character is encountered. A useful alternative to an array of chars in C++ is the std::string class. This class can be used by including the <string> header file. Remember that string is part of the standard library. A useful string function is getline(sourceOfInput, stringVariable) and example might be: std::cout << "Enter fullname: "; getline(cin, name); getline() has an optional third argument, which is char. The function will read up to (not including) that character. this allows me to have a file like: test.txt bread: cheese: eggs: milk: and a getline function like this getline(inFile, stringVariable, ':'); This is all non-working, example code. ![]()
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS! |
|
|
|
|
|
#29 |
|
Expert Programmer
|
First, sorry for my previous statment (im a little slow
)Second, why am i having so much trouble opening a specific file by STRING??? MyCode: cout << "file name to scan?";
getline(cin,s_fileIn,'\n');
s_fileIn.append(".txt");
FileIn.open(s_fileIn,ios_base::in); //line 58ERROR: c:\Documents and Settings\knowell\Desktop\DataSearch\DataSearch\main.cpp(58): error C2664: 'void std::basic_ifstream<_Elem,_Traits>::open(const char *,std::_Iosb<_Dummy>::openmode,int)' : cannot convert parameter 1 from 'std::string' to 'const char *'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Dummy=int
]
__________________
"When in Rome, Do as the Romans Do" "Beauty is in the eye of the BEER holder" "Save your breath your going to need it for your blow up doll later" SearchLores.org |
|
|
|
|
|
#30 |
|
Hobbyist Programmer
|
are you wanting to get input from the user and write that to the file?, if so:
[php] cout << "file name to scan?"; getline(cin,s_fileIn); ofstream myfile (s_fileIn); if (myfile.is_open()) { getline(cin,mystring); myfile << mystring << endl; myfile.close(); } else cout << "Unable to open file"; [/php] (untested code)
__________________
Hoes telling me to calm down but I'm like fuck that shit!
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|