|
What the program actually does is that it searches an input file containing special characters contained in some words(i.e Ô , * and #352; ) .After finding such words it replaces those characters with this (i.e \o^ , \e^ and \sh respectively).I hope you will have the picture now.
SPECIFICATION
Deal with input or check whether input has the following special characters, i.e. read a file of text containing a list of words and check for the occurrence of these characters:
Ô or ô * as used in the word "pôô"
* or * - as used in the word "r*ma"
#352; or #353; - as used in the word "le#353;a#353;a"
If a word has any of these character replace each character by the
following characters respectively:
ô with \o^
* with \e^
#353; with \sh
I would appreciate it if you could could have a short program to sort
this issue out.
Let me say that it should be like this:
input -> words.doc
pôô r*ma le#353;a#353;a aôwô b*thô
output -> c:\output.txt
p\o^\o^ r\e^ma le\sh;a\sh;a a\o^w\o^ b\e^th\o^
Yes the text file is ASCII format(that "#352;" represent an S with a cap on top).It is Northern Sotho language(South African language)
|
|
|
|
|
The simple way is to use a lookup table e.g. char lookup[256];
each element will contain the character that is to be displayed for relevent ASCII value e.g lookup[235] = '?'; The majority will probably be the "standard" ASCII values.
So read in a buffer and use the look up table to convert each character, to a new or the same buffer;
This solution is only really valid if there are a lot of mappings that change, otherwise it can be slow. If there are only a few use a simple case statement for the mapped characters.
Of couse you could look at the ASSCII code chart and see if a simple mask would do the job, e.g. converting lower to upper case.
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
Can't think of an application to do this off the top of my head.
However, if what you are looking for is API capable of doing exactly this you could start with:
1/ boost::regex[^]
2/ System.Text.RegularExpressions in the .NET framework
The benefit of using boost::regex is that you get a little more flexibility.
The benefit of using the .NET framework is you can code it in C# and it'll be about 1/4 the size.
|
|
|
|
|
How can i convert _int64 to string? Normally whenever i need to convert numbers to string i use the following code:
**************************************
int num = 123;
std::string strNum;
std::strstream strm;
strm << num << std::ends;
strNum = strm.str();
***************************************
This always works fine for me if the data type of a number is 'int' or 'float'. Today for the first time i need to convert an '_int64' number to string. I am using the code i described above but i get the following error:
ServerMain.cpp(79) : error C2593: 'operator <<' is ambiguous
Can anyone tell me the cause of problem and its solution
|
|
|
|
|
_int64 is a compiler specific data type. Therefor it is not supported by the STL which is by design compiler independant (at least it's supposed to).
You can use the printf() family of functions, they support _int64 via the prefix I64 (but only on MSVC). So this should work:
sprintf(my_char_buffer, "%I64i", my_int64_num);
- askadar
|
|
|
|
|
askadar wrote:
_int64 is a compiler specific data type. Therefor it is not supported by the STL which is by design compiler independant (at least it's supposed to).
However true, it's also irellevant. The STL (which technically has no merit any more, since Mars 1998) didn't even touch the matter.
If we on the other hand talk about the C++ library: vendors are free to extend the library with e.g. compiler specific data types, and both Dinkum (MSVC7 and __int64, though with the name _LONGLONG) and the GNU C++ lib do provide these insertion operators for 64-bit integers (VC6 is another matter, but it's very easy to augment the lib to handle 64-bit integers).
In fact I expect (especially for proprietary) compiler/lib combos to provide operators for all of the compilers POD types. I almost wrote "native types", but stopped myself knowing that any IA32 64-bit integer support must be emulated.
|
|
|
|
|
Hi CPians !
My MFC Dialog app needs to be runned single under NT/XP. To that end I use PJNaughter's single instance which works very fine. I have associated some config files to my app, so that when the user double clicks on them, my app is opened. So far so good.
If my app is already running when the user double clicks on a cfg file, I'd like to send a message from the second instance to the first with the name of the file to open in it, so that i can open the config file in the first, and kill the second.
BUT I can't get this to work.
I use a registered message, which is arriving properly and handled properly with ON_REGISTER_MESSAGE, but I can't retrieve the sent string. :
App2 (which is to be terminated) :
CString Filename="C:\\Myfile.cfg";
::SendMessage(WM_USER_2NDOPEN,(WPARAM)(Filename.operator LPCTSTR()),0);
App1 (which should process the message :
LPCTSTR buff;
buff=(LPCTSTR)wParam;
won't work. I have tried about everything, using LPSTR, LPCSTR, LPTSTR, LPCTSTR (so Unicode and not Unicode), even a CString, or a char[1024] or a char * (I know some of these solutions are redundant) passing each time the address of the string to the first app, and tried every possible configuration of typecasts in the receiving function, but I can't seem to retrieve the sent string (most time, when the casts make sense, I have "IIIIIIIIIIIIIIIIIIIIIIIIIIIIII..." in the buff). And the Send instead of Post makes sure the string does not get destroyed before I read it from memory.
The weirdest thing is that if I replace the CString, or the LPCTSTR or what in the App2 with :
::SendMessage(WM_USER_2NDOPEN,(WPARAM)"RaGE",0);
Then I can retrieve the string without any problem, whatever the format and typecast I use in the receiving function in App1.
My temporary solution is that I save the filename in a text file on the disk in C:\\Temp in App2, send the message and retrieve the name by reading it frim the file in App1. But I think this solution really sucks.
I'd like to do it the right way, and I'm sure it _is_ possible to send a string using a windows message...
Can you help me ?
~RaGE();
|
|
|
|
|
Hi,
I need to show different tooltips for different positions in the same window.How to implement this.
|
|
|
|
|
First of all, check the rect position of tooltips, and make tooltips each and all.
I implemented it once.
There are two men, one is a programmer, another is a man.
|
|
|
|
|
I made a printer driver installing program.
Adding printer and adding printer driver work perpectly.
In adding printer, I check that the same printer driver have been already installed with OpenPrinter().
I use a handle from OpenPrinter() to implement DeletePrinter(). I think this is common way.
But DeletePrinter() don't work.
DesiredAccess, member of PRINTER_DEFAULTS that specifies desired access rights for a printerstructure, affect the operation of the SetPrinter and DeletePrinter functions on MSDN.
So I did OpenPrinter() with setting DesiredAccess, but this cause an error, Unhandled exception in Install.exe (WINSPOOL.DRV):0xC0000005:Access violation.
Please advise me after check my source following.
////////////////////////////////////////////////////////////////////////////////////////////
PRINTER_DEFAULTS stPD;
HANDLE hPrt;
stPD.DesiredAccess = PRINTER_ALL_ACCESS;
if ( OpenPrinter( (char*)(LPCTSTR)sName, &hPrt, (LPPRINTER_DEFAULTS)&stPD) )
{
sTmp = "Already, same driver is installed.\nReplace old driver with new driver?";
if (IDYES != MessageBox(sTmp, sCoName, MB_ICONQUESTION|MB_YESNO))
{
MessageBox("Driver install is canceled.");
return;
}
if (!DeletePrinter(hPrt))
{
sTmp.Format("Can't delete driver (Error No. %d)", GetLastError());
MessageBox(sTmp);
return;
}
}
|
|
|
|
|
Hi Everyone,
How to make a program in VC++ to send E-mail in which including :-Subject,To,Bcc,Cc,Text.
Thanx,
|
|
|
|
|
One solution is winsock.
Kuphryn
|
|
|
|
|
How to interact with mail server.
Thanxs.
|
|
|
|
|
Search Google for the format to logon to an email server. Format the outgoing string data. Send via winsock.
Kuphryn
|
|
|
|
|
Check out the following links:
http://www.axter.com/code/SendEmail.h
http://www.axter.com/code/SendEmail.cpp
This is a SendEmail that you can use with an SMTP server.
The class does all the leg work for you.
Top ten member of C++ Expert Exchange.
http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/
|
|
|
|
|
I am wondering if the VC compiler uses multiple threads in compiling source code, i.e. will compilation speed scale linearly with number of processors?
|
|
|
|
|
Stormwind wrote:
I am wondering if the VC compiler uses multiple threads in compiling source code
No. 
|
|
|
|
|
when i create a project following the wizard, I may find
the final installation files include all the files i put
into the file group of this project such as my exe file,
my icon file and so on.
Someone told me I can create a single setup.exe file by
using the tool PackageForTheWeb of installshield, but I
still want to know how can i create a project only include
some installshield stardard files (i.e. data1.cab,
licence.txt, setup.exe and so on) just like some other
softwares. I think all my own program files should be in
the data1.cab, shouldn't it?
Thank you.
|
|
|
|
|
Why don't run the same programe code on vc++ compiler,but it is run good on dev-c++ compiler.
The code is
#include "stdafx.h"
#include <windows.h>
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
char szClassName[ ] = "AltWind";
HWND hwnd;
MSG messages;
WNDCLASSEX wincl;
wincl.hInstance = hInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_HREDRAW | CS_VREDRAW;
//wincl.cbSize = sizeof (WNDCLASSEX);
wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
//wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
if (!RegisterClassEx(&wincl))
{
MessageBox(NULL,TEXT("this program required windows nt!"),
szClassName,MB_ICONERROR);
return 0;
}
hwnd = CreateWindowEx(
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"Windows App", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hInstance, /* Program Instance handler */
NULL);
ShowWindow (hwnd, nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&messages,NULL,0,0))
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
return messages.wParam;
}
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static POINT aptFigure[10]={10,70,50,70,50,10,90,10,90,50,
30,50,30,90,70,90,70,30,10,30};
static int cxClient,cyClient;
HDC hdc;
//RECT rect;
//GetClientRect(hwnd,&rect);
//cxClient = rect.right - rect.left;
//cyClient = rect.bottom - rect.top;
int i;
PAINTSTRUCT ps;
POINT apt[10];
//HPEN hPen;
switch (message)
{
case WM_SIZE:
cxClient = LOWORD(lParam);
cyClient = HIWORD(lParam);
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd,&ps);
SelectObject(hdc,GetStockObject(GRAY_BRUSH));
for (i=0;i<10;i++)
{
apt[i].x=cxClient * aptFigure[i].x/200;
apt[i].y=cyClient * aptFigure[i].y/100;
}
SetPolyFillMode(hdc,ALTERNATE);
Polygon(hdc,apt,10);
for(i = 0;i < 10; i++)
{
apt[i].x += cxClient/2;
}
SetPolyFillMode(hdc,WINDING);
Polygon(hdc,apt,10);
EndPaint(hwnd,&ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0 ;
}
I am like programiing
|
|
|
|
|
No-one is going to wade through your code if you don't even say what the error is, but VC6 is one of the worst compilers for C++ standards conformance.
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
Anonymous wrote:
OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window.
I think you are a good candidate for Visual Basic. - Nemanja Trifunovic
|
|
|
|
|
:(The screen show a dialog box when this program running,the dialog box message is "this program required windows nt!" ,why? but think you too.
I am like programing
|
|
|
|
|
LOL - so the compiler works fine then. If it works with your other compiler and runs, chances are it's inserting a workaround for a function you're calling that is NT only. Or your build settings are creating the problem.
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
Anonymous wrote:
OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window.
I think you are a good candidate for Visual Basic. - Nemanja Trifunovic
|
|
|
|
|
I caeat a Win32 app.But it shouldn't this dialog message,help me to solve this problem. think you ,what are you using compiler?
I am like programing
|
|
|
|
|
sunjohn wrote:
I caeat a Win32 app.
I can see that, I'm not stupid.
sunjohn wrote:
But it shouldn't this dialog message,help me to solve this problem
Well, this code:
if (!RegisterClassEx(&wincl))
{
MessageBox(NULL,TEXT("this program required windows nt!"),
szClassName,MB_ICONERROR);
return 0;
}
seems to be your problem. Now, I presume this means you got the code from somewhere else, if you couldn't work out that this is the source of your dialog, and you blamed the compiler. Either way, your window class is failing to register.
sunjohn wrote:
what are you using compiler?
VS.NET 2003, but I've written lots of Win32 code in VC6.
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
Anonymous wrote:
OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window.
I think you are a good candidate for Visual Basic. - Nemanja Trifunovic
|
|
|
|
|
o!by the way ,I used operating system is win2000.
I am like programing
|
|
|
|
|