|
I want to initialize a vector or a list with data that is stored in a file. I have not seen any example on how to read this data into the vector or list. All I have seen is an array that is initialized and that data is then placed in the vector. I want to open the file and insert the data directly into the vector. Thanks for the help.
Josh
|
|
|
|
|
unfortunately, vectors are not file parsers. you'll have to read the data yourself and then insert it into the vector (as you describe).
-c
30% of your base are belong to the IRS!
|
|
|
|
|
This example opens a file filled with int s separated by whitespace and feed them into a vector:
std::vector<int> v;
std::ifstream ifs("test.in");
std::copy(std::istream_iterator<int>(ifs),std::istream_iterator<int>(),
std::back_inserter(v)); Of course you can do it the non-STL way, opening the file, reading the data one at a time and pushing into the vector with push_back .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
A vector is an array. This is an old WG issue, and will be corrected. You can assume that the following gives you a pointer to 2048 bytes of contigous memory:
std::vector<char> foo;
foo.reserve(2048);
char* p = &foo[0];
|
|
|
|
|
I'm trying to pass a file path with spaces in the cmdInfo.m_strfile. It only excepts the first letters before the space. ie c:\documents and settings. Only c:\documents copyied into cmdInfo.m_strfile. Any ideas.
Thanks
|
|
|
|
|
Put quotes around the file name, maybe?
cmdInfo.m_strFile = _T("\"C:\\documents and settings\"");
This could be worth a try.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
What Michel says should work. You can also get at the command line another way - simply access the app's m_lpCmdLine member variable and avoid ParseCommandLine completely. I guess it depends on what you want to do. If you are ever going to have more than one parameter, you'll have no other choice than to surround the file by quotes.
No generalization is 100% true.
Not even this one.
|
|
|
|
|
Hi there,
I'm making an browser and trying to implement full-screen mode.
Stumbled on a problem.
For now I have this code:
// find taskbar window
CWnd* pWnd = CWnd::FindWindow(_T("Shell_TrayWnd"), _T(""));
if(!pWnd )
return;
/*CRect tr;
pWnd->GetWindowRect(&tr);
int th = tr.Height();*/
if( bHide )
{
// hide taskbar
pWnd->ShowWindow(SW_HIDE);
((CMainFrame*)GetParentFrame())->SetStatusBar();
((CMainFrame*)GetParentFrame())->SetToolBar();
((CMainFrame*)GetParentFrame())->ShowWindow(SW_SHOWMAXIMIZED);
bHide = FALSE;
}
else
{
// show taskbar
pWnd->ShowWindow(SW_SHOW);
((CMainFrame*)GetParentFrame())->SetStatusBar();
((CMainFrame*)GetParentFrame())->SetToolBar();
((CMainFrame*)GetParentFrame())->ShowWindow(SW_RESTORE);
bHide = TRUE;
}
It hides the taskbar, maximizes the window and hides status and toolbar.
The problem is that the window does not overlap the hidden taskbar so its pretty useless.
Now I came along this method;
TaskBarList2::MarkFullScreenWindow
It's supposed to do just what I want, but I can't get it to work right.
If anyone can help me, please do.
|
|
|
|
|
When you generate a standard Win32 library in VS.NET there are several paths stored in the library eg.
the relative path to the obj file - debug\stdafx.obj
the full path to the obj file - c:\test\debug\stdafx.obj
the full path to the PDB file - c:\test\debug\vc70.pdb
Is it possible to alter the location of the PDB file as I have the following problem...
I develop a library on my machine in one directory and then book it into the server (copy it to the server). This file is then copied back to my workstation via a library update batch file into a different directory. Now when I compile a program that uses the library I get linker errors because the linker cannot find the VC70.pdb file for the library. If I put the library source back onto my machine in original directory the link is successful.
Can anybody offer any suggestions as to what I am doing wrong and how to correct my build options / procedures?
Steve.
Systems AXIS Ltd - Software for Business ...
|
|
|
|
|
i've not used VC7 extensively, but as far as i know, a .PDB file is only for debugging - it doesn't contain any code.
what kind of linker error are you getting?
-c
30% of your base are belong to the IRS!
|
|
|
|
|
I am trying to get the mini dump debugging working, as suggested by your good self yesterday. To do this I am creating debug information for release builds in .pdb files via the /Zi command line switch to cl.exe. The error I get when linking my test program is...
TEST.LIB(LIBSRC.OBJ) : warning LNK4204: 'C:\TEST\vc70.pdb' is missing debugging information for referencing module; linking object as if no debug info.
Does this give you any more of a clue as to what is going on? How do people usually maintain libraries? Are they always stored and maintained in the same place?
Systems AXIS Ltd - Software for Business ...
|
|
|
|
|
ah... yeah, the .PDB probably contains path info so that it knows where to find the various source files used in building. it's really not a problem with the .LIB. have you tried copying the .PDB over, too?
-c
30% of your base are belong to the IRS!
|
|
|
|
|
Can i do something like this?
[autorun]
open=iexplorer.exe myhtmlfile.html
icon=myicon.ico
label=Internet Explorer
Is there a way to open it in full screen?
Santiago Suárez R.
|
|
|
|
|
You could do something like...
open=iexplore.exe about:<script%20language=javascript>moveTo(0,0);resizeTo(screen.width,screen.height);location.href='whatever.html';</script> But that becomes rather limited.
I'd suggest having your html file contain the JavaScript needed to pull this off.
Jeremy L. Falcon<nobr>
Homepage : Sonork = 100.16311
"It was a blind man who taught me how to see." - Aerosmith
|
|
|
|
|
Hi,
I am learning C++ and have been doing pretty well until I got to this project I needed to complete. It's just a simple database, nothing fancy. I've imported msado15.dll, and have done eveything by the book but I keep getting this error upon executing the program that says "Data source name not found and no default drive specified. My instructor simply said that some people have an ODBC on thier systems and others don't. If I don't then I wont be able to get this to work. I'd like very much to concentrate on database building and design and was wondering if there is any way around this. I have WinXP Home editiion, and have just gotten (although not installed yet) pro. Any ideas would be appreciated.
I did set up my DSN and just now I did it again thinking that maybe something went wrong the last time. Any other ideas?? Please?
Thanks,
Garry
|
|
|
|
|
If you are using ODBC, why are you importing msado15.dll? ADO is a completely different method for database handling. In either case (ADO or ODBC), you need to have the actual database somewhere before you can use it from your program. What database server are you using?
|
|
|
|
|
I have a database set up in Access. Like I said I am real new to this so any guidence would be really appreciated. I have made a database for reading an ODBC file before and it worked, it never occured to me for some reason that Trying to go through ADO was real different. I have a sample program taht I have been using to learn from and when I am all done putting it together I get a run time error that reads "Data source name not found and no default and no default driver specified."
Is there anything I can do for this?
|
|
|
|
|
A very simle example at http://www.codeproject.com/database/excel_odbc_write.asp
Papa
Murex Co.
|
|
|
|
|
Thanks an aweful lot. I appreciate your help
|
|
|
|
|
Loved to help!
Papa
Murex Co.
|
|
|
|
|
hi,
is it dangerous usnig pointers and mfc containers in a dll?
does using regular stl in a mfc dll cause any memory leak?
bye.
|
|
|
|
|
You've got to be careful about the version of the C run-time library you're using. For the main app and all the DLLs involved this has to be of type DLL (be it multi- or single-threaded, debug or release), and it has to be exactly the same version. Taking this precaution, things should be OK (I think.)
As for the pointers, it is the same situation as with STL with respect to allocation/deallocation in different componenents of the program.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
hi,
I have 2 files-myclass.h & myclass.cpp.
The .h,as usual,contains the declarations and the .cpp the implementation.the class is a hand coded class which doesnot derive from any mfc or others.
Now,i think the compiler is not finding the implementation because I get lnk2001 error.
Why?should i set some project settings or something.i dont see any reason for this everything seems normal.I am really getting kranky with this.
please help.
|
|
|
|
|
Please post the entire message error you're getting, this might help us spot the problem.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
none of the functions are recognised and undefined external link(the general lnk2001) is given.
I have also declared the functions inline but no use
|
|
|
|