|
Hi,
my C++ is very rusty, but I expect cin >> int1; only consumes the digits, not
the NEWLINE I expect you add to it, hence the next getline(cin, str2); will be
satisfied by the int's NEWLINE and return a zero-length string.
The solution would be to not use cin at all, and always use getline, optionally followed by a
string-to-number parser (some atof-like function).
|
|
|
|
|
led mike wrote: Guessing is not considered Best Practice in Software Development.
Unless you are in to heuristic algorithms
|
|
|
|
|
led mike wrote: Guessing is not considered Best Practice in Software Development.
You're right. Most used practice in Software Development is plz give me code urgent plz plz
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Luckily I did not have a mouth full of coffee when I read that!
led mike
|
|
|
|
|
You could try something like this:
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
void main()
{
string str1;
int int1;
string str2;
int int2;
cout < "str1 value: ";
getline(cin, str1);
cout << "int1 value: ";
cin >> int1;
cin.seekg(0, ios_base::end);
cout << "str2 value: ";
getline(cin, str2);
cout << "int2 value: ";
cin >> int2;
cin.seekg(0, ios_base::end);
cout << str1 << " and " << str2 << endl;
cout << int1 << " and " << int2 << endl;
}
Steve
|
|
|
|
|
hmm, no, that didn't fix it.
I got it working just using cin.get() after input of an int. is that a good solution?
|
|
|
|
|
Works me me just fine. Tested it again just then and got the following output:
str1 value: One
int1 value: 1
str2 value: Two
int2 value: 2
One and Two
1 and 2
Steve
|
|
|
|
|
Hi All,
I have an issue with the code,which i have written .
I have written the following logic to extract the file name from a full path(the code is in c.)
TCHAR *filename;
filename = _tcsrchr(FullPath,L'\\');
The above logic is working fine on English machines.But it is failing on Japanese machines ,when specific multi-byte chars are given as part of file name.
If the path is "C:\test\能.html", i am getting ".html" as file name,instead of "能.html"
Any help ??
Thanks
Appu..
"Never explain yourself to anyone.
Because the person who likes you does n't need it.
And the person who dislikes you won't believe it."
|
|
|
|
|
are you building your application with UNICODE turned on ?
|
|
|
|
|
yes..it is happening with the specified character. i will try with _splitpath() and let you know.
Thanks for the reply.
Appu..
"Never explain yourself to anyone.
Because the person who likes you does n't need it.
And the person who dislikes you won't believe it."
|
|
|
|
|
_splitpath(strHTMLFilePath, drive, dir, fname, ext ); is also returning empty string .
can someone help me out ?
Appu..
"Never explain yourself to anyone.
Because the person who likes you does n't need it.
And the person who dislikes you won't believe it."
|
|
|
|
|
How can you use _splitpath() with Unicode strings? Shouldn't that be _wsplitpath()?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Try passing the actual value of the backslash:
TCHAR *filename;
filename = _tcsrchr(FullPath,L'\x05c');
|
|
|
|
|
|
I need to check if Thread is suspended ...then resume it .how could i check thread state
|
|
|
|
|
You may choose to call anyway ResumeThread , since it isn't harmful for running thread (and returns thread's suspend count), [^] see documentation for details.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Did you suspend it or no?
|
|
|
|
|
|
Its of MSDN:
"Each thread has a suspend count (with a maximum value of MAXIMUM_SUSPEND_COUNT). If the suspend count is greater than zero, the thread is suspended; otherwise, the thread is not suspended and is eligible for execution. "
|
|
|
|
|
Help pls, how can I get the value(True/False) of a check box, so that i can save/pass it into a database.
Gpat
|
|
|
|
|
See [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi Friends,
I have developed 3 MFC dll's. I am calling those in SDI application.
I am using create fn to create the dialogs of dll.
I placed the create code in initinstance of SDI app.
The problem is strange...!!
Only 2 of 3 get created other will throw an exception.
I traced the code it hits at
// separately create OLE controls in the dialog template
if (pOccManager != NULL)
{
if (!SetOccDialogInfo(&occDialogInfo))
return FALSE;
lpDialogTemplate = pOccManager->PreCreateDialog(&occDialogInfo,
lpDialogTemplate);
}
(The error line is made bold)
But same works with my other SDI app.Its only problem in main module.which
is developed by other person(He modified the SDI to navigate to different views).
Please help me to get out of this problem.....
Reagards
Shiva
|
|
|
|
|
Hi Friends,
I am trying to use IStoreFolder::RegisterNotification Method from the constructor of my ATL addin dll class for Outlook Express/ Windows Mail.
But it's failing.
Dont know the cause but it's working if I try to run it from my another standalone sample application. (a simple c++ exe)
If anyone knows the reason behind this, kindly reply back.
Thanks a lot.
dolly,
N,IN
|
|
|
|
|
Hi all,
I am having two exe's, I am running one exe through another using API ShellExecute.... Now what i want is i want to pass a value from one exe to another and want to use that value in second exe. How is this possible???
Thanks in advance
|
|
|
|