|
See these articles:/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
These are some cool articles that you've pointed me to, but here is a screenshot of something more along the lines of what I want:
http://www4.ncsu.edu/~jgbishop/images/misc/SyntaxPreview.jpg
This comes from the Open Perl IDE (a great little perl IDE BTW). Maybe I'm just missing an obvious point, but the articles that you've listed seem to be more for the syntax highlighting in an editor. I just want a preview of what colors will look like together...
Thanks!
Jonah Bishop
Visit JGB Productions
|
|
|
|
|
I really need your help guys because I am new to C++ and I don't understand many things.
I want to make a program that reads text files, tokenize the text and print the word frequency (how many same tokens exist in a file).
I have already started the program but now I got stuck.
I have this function which counts the frequency of a word in a file ("out.txt").This file has the tokens, one at each line. (The input text has alreadu been tokenized.) The function is called from main() when I want to count the word occurences of a file. When I call this function again (the file "out.txt" has changed,it has the tokens of the second file) because I want to count the frequency of words in another file, I get the total frequency of words(including the tokens of the previous file)in the file "1.txt".What I do wrong? Is there something happening with the iterator or the const? I really don't know a lot about these things. Here is the functions:
map<string,int> histogram;
void record(const string& s)
{
histogram[s]++;
}
void print(pair<const string,int=""> & r)
{
ofstream fout("eksodos.txt",ios::app);
fout << r.first << ' ' << r.second << '\n';
}
void freq()
{
ifstream fin("out.txt");
istream_iterator<string> ii(fin);
istream_iterator<string> eos;
for_each(ii,eos,record);
for_each(histogram.begin(),histogram.end(),print);
ifstream from("eksodos.txt");
ofstream to("1.txt");
char ch;
while(from.get(ch)) to.put(ch);
ofstream fout("eksodos.txt",ios::trunc);}
Thank you very much in advance
|
|
|
|
|
naja wrote:
ofstream fout("eksodos.txt",ios::app);
fout << r.first << ' ' << r.second << '\n';
Just a guess because I really have never used macros such as for_each, or template classes like istream_iterator, but you don't seem to close your files after you open them. Now that will cause you unpredictable problems.
~Afterall I realized that even my comment lines have bugs~
|
|
|
|
|
Hi,
I'm using one of the classes found elsewhere in codeproject to implement my own server. The question is very simple:
How do I get the ip of my server?
In other words, I want to tell a remote client what my ip is, so that they can
connect.
I browsed through the winsock2 api and tried gethostname() and gethostbyname(), but they don't seem to give me what I want.
thanks in advance
|
|
|
|
|
try this, it's not perfect
1) get your host name gethostname()
2) then call gethostbyname() to resolve your host name
you get a host table back, and the first one should be what you want.
|
|
|
|
|
I'm sorry, I've already tried this.
It returns a string which include the "name" of the computer,
but not the ip address (ie. something like "205.212.12.35")
|
|
|
|
|
let me write that in code, maybe you'll see it this way:
// step 1: get my host name:
char hostName[128];
gethostname( hostName, sizeof(hostName) );
// step 2: convert my host name to an address table
const hostent *pHostRecord = gethostbyname( hostName );
// step 3: grab the first address out of the table.
DWORD ip = *(DWORD *)pHostRecord->h_addr_list[0];
it's not a perfect answer, and get's weird when your machine has more than one IP address (multiple NICs). But in general, this works great.
use "inetntoa()" to convert the DWORD ip to a dotted IP string.
|
|
|
|
|
Thanks Peter,
I have been trying to get the ip from the hostent structure all
along, but I didn't use the DWORD cast you did. I assumed it
was already in the form of a string.
But the code that did it in the end is this:
<br />
char strHostname[128];<br />
gethostname(strHostname, sizeof(strHostname));<br />
hostent *pHostent = gethostbyname(strHostname);<br />
ULONG ip = *(ULONG *)pHostent->h_addr;<br />
in_addr ipaddr;<br />
ipaddr.S_un.S_addr = ip;<br />
m_strServerIP = inet_ntoa(ipaddr);<br />
|
|
|
|
|
I'm quite new to programming and need some help. How do I create a 2 dimensional array when I don't know the size of either axis before compiling? I've used Carray quite nicely before for a 1 dimensional array but I can't fiqure out how to do a 2 dimensional array. I also need the array to adjust its size as new data is added. What I really want is to set up a matrix to access some data with dates on one axis and some int number of the other axis. I don't know anything about CMap, but could this work? If so, how would I set up a CMap?
Thanks in advance.
E
|
|
|
|
|
One solution is a vector.
typedef std::vector<> vec?0;
typedef std::vector<<vec?0>> vec?1;
vec?1 data;
...
Kuphryn
|
|
|
|
|
|
I haven't done a multi-dimenstional array yet. So Its been only a CArray. Can I do a CArray of CArrays? How would I define that?
|
|
|
|
|
template< class TYPE, class ARG_TYPE >
CArray < CArray , CArray& > m_Arrays ;
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
How would I do this if I wanted to use a structure with some variables and a CArray embedded in it?
I have something like this:
struct STest
{
int IndexNumber;
CArray <double,double> Data;
};
And I want to make a CArray of this struct. How do I do this? I'm getting an error when I try
CArray <stest,stest&> FinalArray;
|
|
|
|
|
I am having trouble in getting the bitmap of a font using GetGlyphOutline(). It returns -1 when I try to get the size of the buffer that is required to store the bitmap. I guess it's some problem with device contexts and stuff like that, so someone please tell me in detail how to use it and the DCs i need to create. I am a beginner, so I don't know much about DCs and sing them for the above mentioned stuff.
|
|
|
|
|
Hello,
I have a problem :
I want to create a listbox (syslistview32) with different items background color ....
o line to be blue, and other to be red (background)
it's possible, and if "yes" please can you tell me how ?
the code I want to be NON-MFC something with win32 api
thank you
|
|
|
|
|
te-au lamurit!
|
|
|
|
|
Are there any hard and fast rules or rigor regarding exception processing and propagation from server to client? Are there any handy techniques? Does SetErrorInfo() raise an exception, which if unhandled, will raise on the client side or must the client always check the HRESULT? If the client always has to make that check then it seems to me we have advanced too far w/r to exception handling and propagation.
It would be good to wrap all server side errors into a common class, but isn't that what _com_error is? _com_issue_errorx() is not documented, at least the source. I don't want to have to recreate the wheel as I am on a timeline here. Any help would be appreciated (and, if you know what I mean) it's hard to ask for.
Duncan Wells
|
|
|
|
|
exception should never cross the server boundary. SetErrorInfo() does not throw any exceptions, it just sets up error info data which can be accessed using GetErrorInfo(). COM methods always return HRESULT so the client should check for that, but some smart pointer wrappers (e.g. _com_ptr_t provided by VC++ compiler) wrap these HRESULTS into exceptions and throw those exceptions if HRESULT is not S_OK.
just use smart pointer classes generated by #import directive. if error occurs inside the COM method call, _com_error exception will be raised
hope this helps
|
|
|
|
|
Hi there, I´ve looked through the Shell API doc´s and searched through the MSDN, but cannot find any doc´s about programmatically using/starting the "open with" dialog box. (i.e. right click on a file and choose open with, when double-clicking on a file that has no association, the open with dialog box appears)
Here´s my problem...
Using ::ShellExecuteEx(...) I´m opening a file (with the path, filename etc.),
I get notification from ::ShellExecuteEx if the associated program was successfully started, or an error if no application is asscoiated with the particular file. On recieving this error, I woukd like to show the "Open with" dialog. Anyone got any ideas?
Thanks in advance
Phil
bum... and I thought I´d got rid of all the bugs
|
|
|
|
|
Call
ShellExecute(NULL, "open", "rundll32.exe", "shell32.dll, OpenAs_RunDLL <the_file>", NULL, SW_SHOW);
where <the_file> is the file you need to open.
If you know how to do it without calling rundll32.exe please let me know. All my attempts have ended in nasty failures
rechi
|
|
|
|
|
Thanks, I´ll try it out over the weekend.
I suspect that using one of the shell32.dll exported functions that are not documented
will do the job... but which one ????
Thanks again, I´ll let you know if I find another way
Have a nice one
Phil
bum... and I thought I´d got rid of all the bugs
|
|
|
|
|
Phil.B wrote:
but which one ????
That's easy: OpenAs_RunDLL . The problem was to find out the function's prototype. Check this code:
typedef void (CALLBACK *PRUNDLLOPENAS)(HWND, HINSTANCE, LPCWSTR, int);
HMODULE h= LoadLibrary("shell32.dll");
PRUNDLLOPENAS pOpenAs_RunDLL = (PRUNDLLOPENAS)GetProcAddress(h, "OpenAs_RunDLL");
pOpenAs_RunDLL(hWnd, NULL, "<the_file>", SW_SHOWNORMAL);
FreeLibrary(h);
The best solution.
rechi
|
|
|
|
|
Thanks once again... another question, how did you manage to get the
signature for the dll call, I had a look a the dll, and found all the documented calls, but the others were all with cardinal numbers.
I used the depandancy walker, not exactly high-tech I know.
Anyway, thanks once again
Phil
bum... and I thought I´d got rid of all the bugs
|
|
|
|