Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 28th, 2005, 2:49 PM   #21
Magius Avvail
Newbie
 
Magius Avvail's Avatar
 
Join Date: Nov 2005
Posts: 23
Rep Power: 0 Magius Avvail is an unknown quantity at this point
Quote:
Originally Posted by DaWei
Your resume' readers/interviewers won't give a rat's about that. They have lots more choices available.
lol
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.
Magius Avvail is offline   Reply With Quote
Old Nov 28th, 2005, 2:59 PM   #22
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Nov 28th, 2005, 4:14 PM   #23
B3TA_SCR1PT3R
Hobbyist Programmer
 
B3TA_SCR1PT3R's Avatar
 
Join Date: Jul 2005
Location: Dallas, Texas
Posts: 101
Rep Power: 0 B3TA_SCR1PT3R is an unknown quantity at this point
Send a message via AIM to B3TA_SCR1PT3R
getline (cin,mystring);
so effin simple.......(isnt it?)
__________________
Hoes telling me to calm down but I'm like fuck that shit!
B3TA_SCR1PT3R is offline   Reply With Quote
Old Nov 28th, 2005, 4:19 PM   #24
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
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
Kilo is offline   Reply With Quote
Old Nov 28th, 2005, 5:05 PM   #25
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
"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
DaWei is offline   Reply With Quote
Old Nov 28th, 2005, 5:15 PM   #26
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Is that specific getline from iostream or string?
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Nov 28th, 2005, 5:21 PM   #27
B3TA_SCR1PT3R
Hobbyist Programmer
 
B3TA_SCR1PT3R's Avatar
 
Join Date: Jul 2005
Location: Dallas, Texas
Posts: 101
Rep Power: 0 B3TA_SCR1PT3R is an unknown quantity at this point
Send a message via AIM to B3TA_SCR1PT3R
according to my calculation its from....iostream
__________________
Hoes telling me to calm down but I'm like fuck that shit!
B3TA_SCR1PT3R is offline   Reply With Quote
Old Nov 28th, 2005, 6:22 PM   #28
Jessehk
The Oblivious One
 
Jessehk's Avatar
 
Join Date: May 2005
Location: Ontario, Canada
Posts: 630
Rep Power: 4 Jessehk is on a distinguished road
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!
Jessehk is offline   Reply With Quote
Old Nov 28th, 2005, 7:27 PM   #29
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
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 58

ERROR:

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
Kilo is offline   Reply With Quote
Old Nov 28th, 2005, 10:39 PM   #30
B3TA_SCR1PT3R
Hobbyist Programmer
 
B3TA_SCR1PT3R's Avatar
 
Join Date: Jul 2005
Location: Dallas, Texas
Posts: 101
Rep Power: 0 B3TA_SCR1PT3R is an unknown quantity at this point
Send a message via AIM to B3TA_SCR1PT3R
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!
B3TA_SCR1PT3R is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:00 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC