|
I am now working to read & write a very BIG size file. I have to read the file by taking chunk of 512 KB at a time, but i only knows two way of reading the file.
1. Read text file character by charter;
2. Read text file record by record;
Now i want help from U that how can i read the text file by giving the
block size which describe how much bytes will be readed at one time. please
send (if possible) me a sample code segment which describes the process of
reading & witing files in chunks.
Thanx & waiting for your early reply at tzubairy@yahoo.com
With Regards,
Tariq
|
|
|
|
|
You could just open an ifstream in binary mode, then just do a read().
char buff[512] = {'\0'};
ifstream inFile("C:\\test.dat", ios::binary);
while(! inFile.eof())
{
inFile.read(buff, sizeof(buff));
memcpy(&SomeStruct, buff, sizeof(buff));
}
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
Actualy i have an error when toolbar.bmp have 256 or grater colors. WTL aplication just asserts on loading bitmap.
how to create toolbar with "more colors", not with 16 color !?
----------------------------
never stop coding.
|
|
|
|
|
i do it only with editing atlframe.h
i changed some code, if we are not in WIN_CE block
[code]
/*
ATLASSERT(false);
TBADDBITMAP tbab = { 0 };
tbab.hInst = hInst;
tbab.nID = nResourceID;
::SendMessage(hWnd, TB_ADDBITMAP, nBmp, (LPARAM)&tbab);
*/
HBITMAP hBmp = LoadBitmap( hInst, MAKEINTRESOURCE(nResourceID) );
HIMAGELIST hImageList = ImageList_Create( pData->wWidth, pData->wWidth,
ILC_COLOR32, pData->wItemCount, 0 );
ImageList_Add( hImageList, hBmp, (HBITMAP)NULL );
::SendMessage(hWnd, TB_SETIMAGELIST, 0, (LPARAM)hImageList);
[/code]
====================
maybe there is some other way ?
----------------------------
never stop coding.
|
|
|
|
|
Yes, I did it quite the same way
|
|
|
|
|
Hello, I'v a problem. I want to make a toolbar, plugin or addin for outlook express. I don't know how to do this. If anybody knows then please do let me know.
What is the best way to find anykind of information, for the new kind of project you have to works for. e.g. I just wrote following in google.
Addin outexpress VB 6 or VC 6
I'll be very thankful for the help.
Try to go in 1 direction.
|
|
|
|
|
Hello, I'v a problem. I want to make a toolbar, plugin or addin for outlook express. I don't know how to do this. If anybody knows then please do let me know.
What is the best way to find anykind of information, for the new kind of project you have to works for. e.g. I just wrote following in google.
Addin outexpress VB 6 or VC 6
I'll be very thankful for the help.
Try to go in 1 direction.
|
|
|
|
|
In Alex's excellent article, source code is provided to build and test a COM server. The test used VBScript access/use the component and everything worked as it should.
I then tried testing it using VB6, but got a run-time error (Run time error 249: ActiveX component can't create object) during the form load, which is where I create the object.
What's up?
Here's my code;
Option Explicit
Public theobj As ServicesManager.CServicesMgr
Private Sub Command1_Click()
theobj.Start ("RobService")
Text1.Text = "Started"
MsgBox ("Howdy")
theobj.Stop ("RobService")
End Sub
Private Sub Form_Load()
Set theobj = CreateObject("ServicesManager.CServicesMgr")
End Sub
|
|
|
|
|
Has anybody figured out a way to preallocate a multimap?
|
|
|
|
|
Do you mean to allocate it at compile time? Or do you mean that you know how many entries you will add, and you want to reserve the memory ahead of time?
If the former, I don't believe it can be done.
If the latter, I would suggest making the values pointers, e.g.,
map<string, cfoo*="">. You could potentially preallocate the memory for
CFoos (simple if it is just a struct, otherwise more work). The
memory for the nodes would not be preallocated, but the nodes would
be fairly small.
|
|
|
|
|
Well, I was unaware of the following article when I replied earlier. You may be well aware of it. It applies to maps, but I don't know whether multimaps are supported, I have not spent the time to check.
For what it is worth: http://www.codeproject.com/vcpp/stl/PGIL.asp
|
|
|
|
|
I think you'd have to hook in your own allocator for that.
The std::[multi]map s are implemented as red/black binary trees IIRC, so they are very dynamic in structure, just like a linked list. Hence you don't see a reserve() method in their interfaces.
hashmaps are by definition preallocated, but I'm not sure if hashmaps are part of STL yet.
--
Denn du bist, was du isst!
Und ihr wisst, was es ist!
Es ist mein Teil...?
|
|
|
|
|
Hi
I need a little (or big...) help with my Visual C++ 6.0 compiler because I guess I found a C++ programm using some STL functions which my compiler does not understand. Basically it's about the functions from STL called "mem_fun_ref" and "mem_fun".
In short, I do not get the following little program to get compiled:
/* The following code example is taken from the book
* "The C++ Standard Library - A Tutorial and Reference"
* by Nicolai M. Josuttis, Addison-Wesley, 1999
*
* (C) Copyright Nicolai M. Josuttis 1999.
* Permission to copy, use, modify, sell and distribute this software
* is granted provided this copyright notice appears in all copies.
* This software is provided "as is" without express or implied
* warranty, and with no claim as to its suitability for any purpose.
*/
//#define mem_fun1 mem_fun
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
class Person {
private:
std::string name;
public:
//...
void print () const {
std::cout << name << std::endl;
}
void printWithPrefix (std::string prefix) const {
std::cout << prefix << name << std::endl;
}
};
void foo (const std::vector<Person>& coll)
{
using std::for_each;
using std::bind2nd;
using std::mem_fun_ref;
// call member function print() for each element
for_each (coll.begin(), coll.end(),
mem_fun_ref(&Person::print));
// call member function printWithPrefix() for each element
// - "person: " is passed as an argument to the member function
for_each (coll.begin(), coll.end(),
bind2nd(mem_fun_ref(&Person::printWithPrefix),
"person: "));
}
void ptrfoo (const std::vector<Person*>& coll)
// ^^^ pointer !
{
using std::for_each;
using std::bind2nd;
using std::mem_fun;
// call member function print() for each referred object
for_each (coll.begin(), coll.end(),
mem_fun(&Person::print));
// call member function printWithPrefix() for each referred object
// - "person: " is passed as an argument to the member function
for_each (coll.begin(), coll.end(),
bind2nd(mem_fun(&Person::printWithPrefix),
"person: "));
}
int main()
{
std::vector<Person> coll(5);
foo(coll);
std::vector<Person*> coll2;
coll2.push_back(new Person);
ptrfoo(coll2);
}
Hint: the first compiler error could be ""solved"" by removing the "const" from "void print () const {".
Nevertheless I get the following errors:
E:\myProjects\memfun1\memfun1.cpp(45) : error C2784: 'class std::mem_fun_ref_t<_R,_Ty> __cdecl std::mem_fun_ref(_R (__thiscall _Ty::*)(void))' : could not deduce template argument for '<Unknown>' from 'void (__thiscall Person::*)(class std::basic_st
ring<char,struct std::char_traits<char>,class std::allocator<char> >) const'
E:\myProjects\memfun1\memfun1.cpp(64) : error C2784: 'class std::mem_fun_t<_R,_Ty> __cdecl std::mem_fun(_R (__thiscall _Ty::*)(void))' : could not deduce template argument for '<Unknown>' from 'void (__thiscall Person::*)(class std::basic_string<cha
r,struct std::char_traits<char>,class std::allocator<char> >) const'
The g++ compiler under Linux simply compiles it without problems...
Any help very welcome!
Bye,
T.T.H.
---------------------------------------------
UPDATE:
I hate it when that happens: I search the net for one hour then post the question here and 5 seconds afterwards I find the answer myself...
http://www.gamedev.net/community/forums/topic.asp?topic_id=187903&forum_id=21
So basically it's a problem with the STL implementation of VC6.0.
T.T.H.
|
|
|
|
|
It compiles on VC 7.1.
Kevin
|
|
|
|
|
HI,
I've created an ATL Composite control using ATL COM AppWizard in VC++ 6.0.
I want to print the control from the container application like word.
How to add support for printing this control.
The dialog has buttons and edit boxes and list control.
I tried sending the WM_PAINT message in OnDraw() for each of the controls within the dialog. It just paints the view of list control. Other controls are not rendered.
Your help will be higly appreciated.
Thanks,
Veena
|
|
|
|
|
I am using few classes which r derived from MFC, CMap class. When i include these files in my ATL project which is simple DLL project, i get the following error:
----------------------------------------------------------------------
mfcs42d.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in MyProject.obj
mfcs42d.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in MyProject.obj; second definition ignored
----------------------------------------------------------------------
Can anybody suggest how i can avoid these error and wht is the reason for such an error.
ksd
|
|
|
|
|
As I understand it, MFC does not mix too well with ATL. I've read that it's OK to use ATL in MFC but not so good the other way round. Though in VC7 there are now a number of shared classes. Plus ATL has its own collection classes. If you're using VC7 why not investigate CAtlMap? If you're using VC6 try STL map. Of course this may not be feasible if, as it seems, you have a lot of old code that uses CMap.
Kevin
|
|
|
|
|
If you are using VC7 you can check "Support for MFC" when you create a new ATL project. Unfortunately I don't really know what it does, so I can't help you changing the settings on your current project.
--
Denn du bist, was du isst!
Und ihr wisst, was es ist!
Es ist mein Teil...?
|
|
|
|
|
I was once asked to look at why a process was taking a long time to accomplish a task. One thing the process did was load a large number of entries into a CMap.
I did a bit of experimentation, and found that inserting 300,000 entries into a CMap took a bit over 4 hours. Doing 300,000 lookups on the CMap also took a bit over 4 hours.
I tried an STL map, and found that inserting 300,000 entries took 22 seconds, and looking up 300,000 entries took 19 seconds.
I've never had any use for CMaps. If you can, you might try switching to an STL map.
|
|
|
|
|
Wow! That's a huge difference! Nowadays I go for STL first with new MFC code. Not that I get to do much new MFC code these days. Though sometimes, depending on the context, the MFC stuff can be more convenient, e.g., CString.
Kevin
|
|
|
|
|
I have a modeless dialog with no Edit controls on it. The dialog is created by the WTL wizard. I would like to trap WM_CHAR messages at the dialog level. In the message map for the dialog I have added code like this:
MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
MESSAGE_HANDLER(WM_KEYUP, OnKeyUp)
MESSAGE_HANDLER(WM_CHAR, OnChar)
but no one of the methods gets called when pressing keys on the keyboard.
Any suggestion?
|
|
|
|
|
Sorry if it's wrong forum but there isn't one for OLEDB... Anyway. Is OLEDB simultaneous-multithread-access safe? Also ... using OLEDB - if different threads need to access the same database is it better to open that database from each thread or is it OK to use the same opened database object from different threads at the same time - reuse the connection?
Sorry for such a basic question.
|
|
|
|
|
AFAIK OLEDB is thread safe.
Good luck
-pete
|
|
|
|
|
Hi all,
I want to develope ATL Container (in which i can host other activex control). How do i proceed, App Wizard does not help more to develope the ATL Container.
Please show me the right direction...........
I will realy appriciate any help !
Thank you,
Vishal More
|
|
|
|
|
Take a look at CAxWindow.
|
|
|
|
|