By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,261 Members | 1,325 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,261 IT Pros & Developers. It's quick & easy.

console io

P: n/a
i'm writing a console app using unmanaged c++ that uses cout/cin to request
a few database connection strings and read them into some string variables.
The problem is: after the frist db connection string is entered, the next
set of cout/cin statements is run thru without giving the user a chance to
input the second db connection string the app requires. I think this is
happening because the database connection strings i'm using have semi-colons
(;) in them (name-value pairs separated by semicolons). If I put in simple
strings like adsfkadsf asdflkjads, the io works as expected. I'm pretty sure
the problem is the semi-colons but don't know what to do about it. There are
also equal signs (=) and single quotes (') in the db connection strings.
Anybody know anything about this?

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Jul 22 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a

"alex" <al*************@verizon.net> wrote in message
news:40**********@127.0.0.1...
i'm writing a console app using unmanaged c++ that uses cout/cin to request a few database connection strings and read them into some string variables. The problem is: after the frist db connection string is entered, the next
set of cout/cin statements is run thru without giving the user a chance to
input the second db connection string the app requires. I think this is
happening because the database connection strings i'm using have semi-colons (;) in them (name-value pairs separated by semicolons). If I put in simple
strings like adsfkadsf asdflkjads, the io works as expected. I'm pretty sure the problem is the semi-colons but don't know what to do about it. There are also equal signs (=) and single quotes (') in the db connection strings.
Anybody know anything about this?


I doubt your reasoning is correct. I expect the problem is that you are
mixing numeric and string input incorrectly. That is the usual reason for
this error. But, of course, its impossible to help you fix this problem
because you neglected to post any code.

Post the code and it will get sorted out very quickly.

john
Jul 22 '05 #2

P: n/a
Provider='sqloledb';Data Source='OKSANA\\OKSANA';Initial
Catalog='pubs';Integrated Security='SSPI';User ID=sa;Password=session99
"John Harrison" <jo*************@hotmail.com> wrote in message
news:2h************@uni-berlin.de...

"alex" <al*************@verizon.net> wrote in message
news:40**********@127.0.0.1...
i'm writing a console app using unmanaged c++ that uses cout/cin to

request
a few database connection strings and read them into some string

variables.
The problem is: after the frist db connection string is entered, the next set of cout/cin statements is run thru without giving the user a chance to input the second db connection string the app requires. I think this is
happening because the database connection strings i'm using have

semi-colons
(;) in them (name-value pairs separated by semicolons). If I put in simple strings like adsfkadsf asdflkjads, the io works as expected. I'm pretty

sure
the problem is the semi-colons but don't know what to do about it. There

are
also equal signs (=) and single quotes (') in the db connection strings.
Anybody know anything about this?


I doubt your reasoning is correct. I expect the problem is that you are
mixing numeric and string input incorrectly. That is the usual reason for
this error. But, of course, its impossible to help you fix this problem
because you neglected to post any code.

Post the code and it will get sorted out very quickly.

john


Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Jul 22 '05 #3

P: n/a

"alex" <al*************@verizon.net> wrote in message
news:40**********@127.0.0.1...
Provider='sqloledb';Data Source='OKSANA\\OKSANA';Initial
Catalog='pubs';Integrated Security='SSPI';User ID=sa;Password=session99


Well that's the input, but where's the code?

Clearly your problem isn't with mixing numeric and string input because
there isn't any numeric input above. Nevertheless its impossible to help you
with bugs in your code without seeing the code.

john
Jul 22 '05 #4

P: n/a
after i enter my connect string in response to the first cout, the rest of
the code gets run thru with no stops

if i just enter a simple string like asdfjdasfadsd the code behaves normally

string targetConnectString, repositoryConnectString, tmpStr;

cout << "enter target connection string: ";

cin >> targetConnectString;

cout << '\n'

<< "enter repository connection string: ";

cin >> repositoryConnectString;

cout << '\n';

"John Harrison" <jo*************@hotmail.com> wrote in message
news:2h************@uni-berlin.de...

"alex" <al*************@verizon.net> wrote in message
news:40**********@127.0.0.1...
Provider='sqloledb';Data Source='OKSANA\\OKSANA';Initial
Catalog='pubs';Integrated Security='SSPI';User ID=sa;Password=session99
Well that's the input, but where's the code?

Clearly your problem isn't with mixing numeric and string input because
there isn't any numeric input above. Nevertheless its impossible to help

you with bugs in your code without seeing the code.

john


Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Jul 22 '05 #5

P: n/a

"alex" <al*************@verizon.net> wrote in message
news:40**********@127.0.0.1...
after i enter my connect string in response to the first cout, the rest of
the code gets run thru with no stops

if i just enter a simple string like asdfjdasfadsd the code behaves normally
string targetConnectString, repositoryConnectString, tmpStr;

cout << "enter target connection string: ";

cin >> targetConnectString;

cout << '\n'

<< "enter repository connection string: ";

cin >> repositoryConnectString;

cout << '\n';


Well the problem is that you have spaces in your connection string, this

cin >> targetConnectString;

will stop reading at the first space. The next read will start where the
last one ended, which is why it doesn't stop, its still reading what you
entered last time.

If you want to read a line at a time use getline.

getline(cin, targetConnectString);
getline(cin, repositoryConnectString);

john
Jul 22 '05 #6

P: n/a
that worked! you rule.

"John Harrison" <jo*************@hotmail.com> wrote in message
news:2h************@uni-berlin.de...

"alex" <al*************@verizon.net> wrote in message
news:40**********@127.0.0.1...
after i enter my connect string in response to the first cout, the rest of the code gets run thru with no stops

if i just enter a simple string like asdfjdasfadsd the code behaves

normally

string targetConnectString, repositoryConnectString, tmpStr;

cout << "enter target connection string: ";

cin >> targetConnectString;

cout << '\n'

<< "enter repository connection string: ";

cin >> repositoryConnectString;

cout << '\n';


Well the problem is that you have spaces in your connection string, this

cin >> targetConnectString;

will stop reading at the first space. The next read will start where the
last one ended, which is why it doesn't stop, its still reading what you
entered last time.

If you want to read a line at a time use getline.

getline(cin, targetConnectString);
getline(cin, repositoryConnectString);

john


Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Jul 22 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.