|
Hi,
I want to know that can i store output from readdir() function in an array. I have a c program
#include <dirent.h>
#include <stdio.h>
int main(void)
{
DIR *d;
struct dirent *dir;
d=opendir("C:\\");
printf("Directories in C:\\ \n");
while((dir=readdir(d))!=NULL)
{
printf("%s\n",dir->d_name);
}
closedir(d);
return(0);
}
Instead of printing directories in output i want to store that result in an array.can it is possible?
|
|
|
|
|
Replace the printf statement with code that fills up a string array?
Do you have a problem doing that?
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
hey Rajesh R Subramanian,
i tried this thing also but i was not working properly. can you please give the correct code?
|
|
|
|
|
I'm curious if anyone uses the macros defined in sal.h (__in, __out, etc.)?
|
|
|
|
|
Yes! I've tried using it sometime back, but then lost interested after realising that it is not worth all the efforts. Not to mention how difficult it was while the function signatures had to be changed.
Still a very nice thing to do though.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
I have 2 dialog boxes. One for writing into a file and other for reading from the file. I am using 2 threads. One WriteThread and one ReadThread.
When i run the application , i am not able to access the 2 dialogs synchronously.When the second dialog is displayed, i am not able to access the first dialog. Means after displaying the second dialog, i have to close it to get the first dialog.
Anyone know the solution?
|
|
|
|
|
ratprita wrote: Anyone know the solution?
You will probably need to use the ModeLess type of dialog. See the Dialog Boxes[^] reference on MSDN for details.
|
|
|
|
|
I tried this.
I have made the second dialog modeless.
My requirement was that when i click on the button on the 1st dialog, 2nd dialog will be activated.
Now after making the 2nd dialog modeless, i am getting the 2nd dialog on each click on the 1st dialog's button . ie, more than one dialog(2nd) is activated.
What is the problem?
|
|
|
|
|
ratprita wrote: What is the problem?
I think the problem may be in the design of your application. Dialogs should be used as short lived windows, to give information to the user, or to get parameters or other information from the user. If you need to have two dialogs active at the same time than you are really heading for trouble. I would take a look at your design and think through what you are trying to achieve.
|
|
|
|
|
Declare the two dialog as the member variable of the invoking window, and pass the window to the dialog when constructing it.
====
Of course it's not the only solution.
|
|
|
|
|
|
At compile time: maybe.
At run time: no.
I do a lot of cleanup of old code, and I can tell you that parentheses could have avoided some of the bugs I find. Even if not strictly required for correct grouping, using parentheses makes clear the coder's intent, and so eliminates potential misunderstandings by Those Who Come After.
|
|
|
|
|
I don't think so, even at compilation time, it might make things easier for the parser.
But don't quote me on that...
This signature was proudly tested on animals.
|
|
|
|
|
I'm trying to write my code independent of text encoding, which is a trivial matter for c-strings, however I'm not sure what the appropriate solution is for std::string...
At the moment I'm using the following...
#ifdef UNICODE
typedef tstring wstring;
#else
typedef tstring string;
#endif
this works for most cases, however I'm stuck when using stringstreams - I often manipulate strings with them and get the result using stringstream::str() - but of course that wont work if I'm using my tstrings because there's no appropriate conversion available. I guess my questions here are, A) is the above snippet the best way to do it, B) is there already a tstring defined somewhere that I may have missed, and C) how do I get stringstream::str() to return an encoding-independant string?
|
|
|
|
|
Yeah, that's the way to do (except that you inverted the typedef fields). You should also typedef stringstream the same way:
#if defined _UNICODE || defined UNICODE
typedef std::wstring tstring;
typedef std::wstringstream tstringstream;
#else
typedef std::string tstring;
typedef std::stringstream tstringstream;
#endif
|
|
|
|
|
In addition to Cedric's answer - I'd be tempted to insert the typedef's into the std namespace, to make ADL (aka Koenig Lookup) work more smoothly. Oh - and you can use TCHAR to remove the conditional compilation:
namespace std
{
typedef basic_string<TCHAR> tstring;
typedef basic_stringstream<TCHAR> tstringstream;
}
This article[^] would probably be of interest as well
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
thanks for the help guys. So basically I need to do that for std::string, std::ostream, std::istream, std::iostream, std::istringstream, std::ostringstream, std::stringstream, std::ifstream, std::ofstream, std::fstream, std::filebuf, std::ios, std::streambuf, std::streampos, and std::stringbuf?
That's seems like a bit of work, so I'm kinda surprised that a header such as tchar.h even exists without encoding-independent versions of the above 
|
|
|
|
|
tchar existed before STL, IIRC?
Anyway - that article I pointed you at has a header with the relevant typedefs and stuff that you can download
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Ah, I missed that. You linked to the reply not the article 
|
|
|
|
|
So I did - that's what Google gave me, so I'll blame them
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I want to implement a dde server in vc++ so that excel get data from dde server . how can I implemmented this . give me some piece of code .
Trioum
|
|
|
|
|
Hi
I have a callback, I would like to recover the string from Variant :
OnEvent(const Variant &toto)
{
//I want to put the contained of toto in my string titi
AnsiString titi = ??
}
Can anyone help me?
thanks
|
|
|
|
|
just try API VariantChangeType [^]
Величие не Бога может быть недооценена.
|
|
|
|
|
thanks
but when i use VariantChangeTypeit doesn't compile([BCC32 Error] test.cpp(7076): E2034 Impossible to convert 'const Variant *' to 'tagVARIANT *'
why?
OnEvent(const Variant &toto)
{
//I want to put the contained of toto in my string titi
VariantChangeType(&toto, &toto, VARIANT_NOUSEROVERRIDE, VT_BSTR);
AnsiString titi((wchar_t*)toto.bstrVal);
}
|
|
|
|
|
hi all,
I came across an peculiar scenario and had to use TerminateThread inevitably (i hate TerminateThread and ExitThread). but when i call TerminateThread on my thread handle it returns error code 183 (ERROR_ALREADY_EXISTS) what is this means?
|
|
|
|