|
int MultiBytetoWideChar(....)
look up the MSDN for detail
路漫漫其修远兮,吾将上下而求索。
|
|
|
|
|
Do you have a unicode string, or a TCHAR string? If it's a TCHAR, use the ATL T2A() macro, as it will work correctly regardless of whether you're compiling for unicode or not.
If it's a true unicode string (using WCHAR), use the WideCharToMultiByte() function.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Q.1 Write a C Program to display following menu
Menu
1. Display
2. Copy
3. Append
4. Exit
Accept the choice (1-4) from the user, and perform following tasks:
Choice 1: Accept a file name from the user and display the file on screen
Choice 2: Accept two file names, and copy first file to the second
Choice 3: Accept two file names, and append second file to the first file
Choice 4: Terminate the program
Your program should have appropriate validations
============================================================
Q2) Write a C Program to create a structured data file named Student.dat to store the roll no, name and course.
Provide following functions:
Accept the values from the user using structure variables. Store the contents in a file.
Display the file.
The user should be able to add new records to the existing file. And display the new file.
============================================================
Q3) Write a C Program to declare an array for 2 0 floats. Accept the values from the user sort the two arrays in descending order. Merge the two arrays into a new array and display the new array.
============================================================
Q4) Accept any two numbers from the user. Perform the following operations on it using functions:
Addition
Subtraction
Multiplication
Swap the values
Print both the numbers in reverse order for example (if a given number is 234, it should be printed as 432)
thx
|
|
|
|
|
If you need help with your assignment, you need to first attempt to write the program, and, then, ask specific questions.
|
|
|
|
|
That's pretty sad, man. You should at least try. Did you post this word for word from your professor's assigment sheet? If you can't do this simple stuff and are not driven enough to even *try* to figure some of it out, you should probably get out of computer science. It's really not some easy way to make a good salary when you graduate. You have to actually apply yourself to be successful in this industry. Not understanding doesn't make you stupid, but cheating does.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
The entire test project can be downloaded at http://www3.telus.net/pja/pja_format.zip. I am planning to write an article on this so I do not mind sharing what I got so far.
This is my header file:
#pragma once
#define USE_STRSTREAM
#ifdef USE_STRSTREAM
#include <strstream>
#else
#include <sstream>
#endif
class pja_format
{
...
public:
template <class T> static const char * tostring (const T &t)
{
#ifdef USE_STRSTREAM
std::strstream s;
#else
std::ostringstream s;
#endif
s.setf(std::ios::fixed);
s.precision(precision);
s << t << std::ends;
#ifdef USE_STRSTREAM
return s.str();
#else
return s.str().c_str();
#endif
}
template<> static const char * tostring (bool b)
{
return b ? "true" : "false";
}
}; I have got the demo working in ANSI if I use strstream, but I want to port it to work with UNICODE now, so I have to switch from strstream to stringstream. The problem is that stringstream seems to totally screw up my programs input. Is it somehow using a shared static buffer? I really do not know what is going on and I am getting totally frustrated.
If someone wants to check it out, download the entire test project from here (4 KB zip)[^] and try it out. comment out the #define USE_STRSTREAM line in the header and see the difference in the output. The really weird stuff happens in the make() member function when trying to read the va_list variables.
Any help would be greatly appreciated.
[EDIT]
I any one is interested in making this a joint project, I do not mind co-authoring the article with someone and sharing the credit. The main thing for me is getting this to work.
[/EDIT]
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
-- modified at 15:51 Friday 10th February, 2006
|
|
|
|
|
I've had a brief look at the code in the debugger (VS 2k5). From what I can see, the va_list magic fails for some reason when USE_STRSTREAM isn't defined. . When USE_STRSTREAM is defined, the VariablesVector contains { format string with \x001s, "This String comes from the Test class - \x0011 \0x0012 \x0013 \x0014", "Hello World", "false" } but when it is not defined, it contains { "", "s", string of 0xCC, "false" }.
I'll see if I can find what's causing it...
|
|
|
|
|
I know what it is that causing the trouble. Dead objects... in both cases actually! But you're lucky in one the cases! Let's consider the #undef USE_STRSTREAM case:
template <class T> static const char * tostring (const T &t)
{
...
return s.str().c_str();
}
s.str() returns a std::string object by value (temporary object). It in turns returns a direct pointer to its internal buffer by use of .c_str(). But... the temporary object dies on returning from the function. So you'll end up returning a direct pointer to the internal buffer of a dead object.
It would seem that you are extremely lucky in the #define USE_STRSTREAM case, as std::strstream seems to leave a seemingly intact buffer after its demise.
|
|
|
|
|
A rookie mistake that I should have seen. Thanks Jorgen.
I was so focused on the stringstream class being the problem that I missed the obvious. Now I just have to figure out a work around so that I can still get my class to do what I want.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
PJ Arends wrote: A rookie mistake that I should have seen. Thanks Jorgen.
It happens to the best every once in a while. Mistakes of this kind often indicates that you need a break. Perhaps it's time for snacks, refreshments and ice hockey?
By the way, I found an error which the VC6 compiler accepts(!)
template<> static const char * tostring<bool> (bool b) should be
template<> static const char * tostring<bool> (const bool& b) .
PJ Arends wrote: Now I just have to figure out a work around so that I can still get my class to do what I want.
How about returning a std::string? I'm not certain about the internals of std::string in any implementation, but I would assume that reference counting and copy on write methods are widely use, which should give little or no penalties for returning such objects.
|
|
|
|
|
Jörgen Sigvardsson wrote: How about returning a std::string? I'm not certain about the internals of std::string in any implementation, but I would assume that reference counting and copy on write methods are widely use, which should give little or no penalties for returning such objects.
I will look into it. The problem may come in how the va_list in the make() function handles std::strings as the type of the variable gets lost in the variable list (at least according to MSDN), which is why I wanted to use char* pointers. I am going to take a break now and look at it again later. Thanks for the help so far.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Is there an API available to enable/disable Windows SP2 firewall on a given connection?
I’ve read through the Windows SP2 Firewall API, but it seems there is no mean to do this, neither enabling nor disabling “pop3”, “FTP server”…etc on a given connection.
These properties are displayed in the Windows SP2 Firewall GUI under ‘Network connection settings’ of the ‘advanced’ tab! There were some methods to do this with ICS/ICF…
Thanks!
|
|
|
|
|
|
hey guys
i've recently started a nex project and this time i want to make things more fancier; i'm going to output the program in a windows window
i've written the code for creating such a window, but i have one error and i don't seem to be able to sort it out
The error is:
Error E2040 bcc11.cpp 5: decleration terminated incorrectly
can anyone help?
(i'm using borland c++ compiler 5.5 btw)
here's the code:
<br />
#include <windows.h><br />
int WINAPI WinMain(HINSTANCE instance, HINSTANCE previousInstance, LPSTR commandLine, int show);<br />
int main();<br />
{ LRESULT CALLBACK WindowProc(HWND windowHandle, UINT message, WPARAM wParam, LPARAM lParam)<br />
return DefWindowProc(windowHandle, message, wParam, lParam);<br />
WNDCLASS myWindowClass<br />
{<br />
myWindowClass.hbrBackground = (HBRUSH) GetStockObject(TRANSPARENT_BRUSH);<br />
myWindowClass.hCursor = LoadCursor(NULL, IDC_ARROW);<br />
myWindowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);<br />
myWindowClass.hInstance = instance;<br />
myWindowClass.lpfnWndProc = WindowProc;<br />
myWindowClass.lpszClassName = "StandardWindowClass";<br />
myWindowClass.style = CS_VREDRAW | CS_HREDRAW;<br />
myWindowClass.style = CS_VREDRAW | CS_HREDRAW;<br />
myWindowClass.cbClsExtra = 0;<br />
myWindowClass.cbWndExtra = 0;<br />
RegisterClass(&myWindowClass);<br />
}<br />
<br />
HWND myWindowHandle = CreateWindow(<br />
"StandardWindowClass",
"Test bcc11",
WS_OVERLAPPED | WS_VISIBLE | WS_SYSMENU,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
0, 0,
instance,
0);
<br />
MSG msg;<br />
<br />
do<br />
{<br />
if (PeekMessage(&msg, myWindowHandle, 0, 0, PM_REMOVE))<br />
{<br />
TranslateMessage(&msg);<br />
<br />
DispatchMessage(&msg);<br />
<br />
}<br />
} while (true);<br />
{<br />
switch (message)<br />
{<br />
case WM_CLOSE:<br />
{<br />
PostQuitMessage(0);<br />
<br />
return 0;<br />
}<br />
}<br />
<br />
return DefWindowProc(windowHandle, message, wParam, lParam);<br />
} <br />
while (msg.message != WM_QUIT);<br />
}<br />
Thanks alot!
Peter
|
|
|
|
|
the include should be #include <windows.h>
sorry for the double post!
|
|
|
|
|
what the hell?!
why isn't this thing showing my included file?!?!?!
it's the windows.h file that should be inculded windows . h
for some reason < windows . h > isn't shown...
sorry for the triple post but i don't know why it doesn't show that filename...
|
|
|
|
|
Peter Charlesworth wrote: for some reason < windows . h > isn't shown...
You need to click the < and > buttons above the smileys.
Peter Charlesworth wrote: sorry for the triple post...
Just modify the one until you get it right. Preview helps in this endeavor.
Also, use <pre> tags instead of <code> tags so that your indention is preserved.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Yes, you're right, david
I'll do just that next time
Still, my problem remains
can anyone help?
|
|
|
|
|
|
Is there a way to insert a item into a list control with the LVIS_STATEIMAGEMASK already set to "checked"?
I am trying to catch a LVIS_STATEIMAGEMASK change in OnLvnItemchanged and I don't want to catch the initial population of the list.
Right now I insert the item into the list control then SetCheck(0) that causes me to catch the LVIS_STATEIMAGEMASK change when the list is first populated.
Any Ideas?
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
RobJones wrote: I am trying to catch a LVIS_STATEIMAGEMASK change in OnLvnItemchanged and I don't want to catch the initial population of the list.
One way around this is to set a flag variable to true before populating the list, and then set it to false after populating the list. Then in the OnLvnItemchanged() method, don't do anything if the flag variable is equal to true. Make sense?
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Yeah I'll have to set it up that way... I guess I was just wondering if it was possible to set the lvi to a checked state before inserting it into the control. Guess not.
Thanks for your help!
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
An edit box is being used for displaying the status of loop iterations. It uses the following approach:
ebptr->SetWindowText(s);
UpdateWindow(FALSE);
How can one get the updated edit box text to display before continuing?
Thanks in advance.
-jon
|
|
|
|
|
Even though a WM_PAINT message was sent to the window's queue, it won't get processed because the loop is not yielding control of the CPU.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Use RedrawWindow() specifing the RDW_UPDATENOW flag to force a WM_PAINT message to be sent to the window.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|