|
first, sorry my english is a little^^;
i type a cod about binary search.
first, i make Video class.
and i want video class to save some andy txt file.
this is my code.
i think ,
there is some problem at write method.
but i don't know why it is happened....
please give me your advice~
#include<iostream>
#include <string>
#include <fstream>
using namespace std;
class Video
{
private:
char *name;
int number;
public:
// ifstream fin;
// ofstream fout;
Video()
{
name = new char[30];
strcpy(name , "nothing");
number = 0;
}
Video(char *imsi_name, int imsi_number)
{
name = new char[strlen(imsi_name)+1];
strcpy(name, imsi_name);
number = imsi_number;
}
int Get_number()
{
return number;
}
char *Get_name()
{
return name;
}
void Set_number(int k)
{
number = k;
}
void Set_name(char *imsi)
{
delete[] name;
name = new char[strlen(imsi)+1];
strcpy(name, imsi);
}
};
void main()
{
Video *v[100];
Video *v4[10];
Video v3;
int i; //point index
ifstream fin;
ofstream fout;
fout.open("c:\\video3.txt", ios_base::out | ios_base::app | ios_base::binary);
fin.open("c:\\video3.txt", ios_base::in | ios_base::binary);
v[0] = new Video("kk1", 1200);
v[1] = new Video("kk2", 2200);
v[2] = new Video("kk3", 3200);
// cout << sizeof(Video) << endl;
// cout << sizeof(kk) << endl;
// cout << sizeof(kb) << endl;
//cout << v.Get_number() << " " << v.Get_name() << endl;
//cout << "size of v" << sizeof(v) << endl;
for(i = 0; i < 3; i++)
{
fout.write( (char*)v[i], sizeof(v3) );
i++;
}
fout.close();
// while(fin.read( (char*)&v3, sizeof(v3) ))
//
// {
// cout << v3.Get_name() << " : " << v3.Get_number() << endl;
//
// }
//cout << "size of v4: " << sizeof(v4[0]) << endl;
i = 0;
while(fin.read( (char*)v4[i], sizeof(v3) ) )
{
cout << v4[i]->Get_name() << " : " << v4[i]->Get_number() << endl;
i++;
}
}//main
Thank you!!
|
|
|
|
|
What do you want to do with write and what is happening instead?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
i put this value into video.txt file.
but those value can't be display and i think that value especially
*name don't save into video file.
how about complie with your computer?
sorry, my explanin is not good~
v[0] = new Video("kk1", 1200);
v[1] = new Video("kk2", 2200);
v[2] = new Video("kk3", 3200);
hi
i am from korea.
My english is a little.
anyway, nice to meet you~~
and give me your advice anytime~
|
|
|
|
|
You have to explicitely write the string inside the file. You can do it also with a method of your class.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
sorry, i can't understand what you mean...
May i request you to fix my source? or can you give me the method to fix?
thank you for taking care my question.
hi
i am from korea.
My english is a little.
anyway, nice to meet you~~
and give me your advice anytime~
|
|
|
|
|
I gave a better look at your code, probably you need object serialization , i.e. a rather difficult mechanism for a beginner. Since MFC supports object serialization http://msdn2.microsoft.com/en-us/library/6bz744w8(VS.80).aspx[^], using this class library maybe an advantage.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
thank you for giving me helpful.
have a nice day pallini~
hi
i am from korea.
My english is a little.
anyway, nice to meet you~~
and give me your advice anytime~
|
|
|
|
|
I tried "MoveWindow", there is a problem.
GetClientRect(&rt), rt.top is 0, after change rt.left, and MoveWindow, the toolbar will be covered by the new client. The coordiantes are not consistant.
I also tried "SetViewportOrg", it works well, however, if MoveWindow can work properly, I will choose MoveWindow to implement it for less problems in the future.
|
|
|
|
|
Have you tried CControlBar or any of it's derivative classes?
|
|
|
|
|
Never, I'll try.
Thanxxxxxxxx
|
|
|
|
|
hi ,
i am trying to open a file and search a specific name on it, see the code below, but not able to find method, what could be the code in place of ???????.
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
void main()
{
FILE *in, *out;
int i;
char str[100];
clrscr();
in=fopen("B.txt","r+");
if(!in)
{
printf("can not open input file");
exit(0);
}
out=fopen("newB.txt","w");
if(!out)
{
printf("can not open output file");
exit(0);
}
while (!feof(in))
{
fgets(str,100,in);
//for(i=0;str[i]!=null;i++)
fputs(str,out);
fclose(out);
fclose(in);
}
|
|
|
|
|
|
maryam_s wrote: what could be the code in place of ???????.
Where are they?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Did you see this link I think it sovles your problem when you it finds words you can insert them to a array(like CStringArray) and then make a new file with CFile class and use of CFile::write.
|
|
|
|
|
I tested CCJButton, but find nothing special,
even worse when CButton is replaced with CCJButton, I move the mouse onto the button, the text is disappeard.
I think CJ60Lib in my project is not working properly.
Is there any document or examples?
|
|
|
|
|
|
make the windows and controls looks better
|
|
|
|
|
|
Because with a free skin library, I can save a lot of time. I don't have much free time by now.
|
|
|
|
|
If you dont have a free time so librarys are good.;)
|
|
|
|
|
Hi All,
After inserting a item is Explorer's shell, one must call DrawMenuItem( hWnd ) to to update the menu. However, the code which inserts the menu item does not receive an hwnd. Any ideas how to obtain the hWnd from an hMenu? Below is the context which DrawMenuBar() would have.
Jeff
HRESULT CTest::QueryContextMenu( HMENU hmenu, UINT uMenuIndex,
UINT uidFirstCmd, UINT uidLastCmd, UINT uFlags )
{
uidLastCmd;
if( uFlags & CMF_DEFAULTONLY )
{ return MAKE_HRESULT ( SEVERITY_SUCCESS, FACILITY_NULL, 0 ); }
if( m_count > 1 )
{
InsertMenu( hmenu, uMenuIndex, MF_BYPOSITION,
uidFirstCmd, _T("String 1") );
}
else
{
InsertMenu( hmenu, uMenuIndex, MF_BYPOSITION,
uidFirstCmd, _T("String 2") );
}
HWND hwnd = null;
DrawMenuBar( hwnd );
return MAKE_HRESULT( SEVERITY_SUCCESS, FACILITY_NULL, 1 );
}
|
|
|
|
|
An old VC++ thread yielded this:
Christian Astor wrote: You can use FindWindow("#32768", NULL) ;
(eg on WM_INITMENUPOPUP )
IMHO, the belief here is that you will be able to find the active Menu's window by that special ID.
Good luck!
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Is anyone aware of some software ideas to keep a small number of computers (e.g. 12) synchronised Real Time Clock Wise.
N.B. Terminals range from Win95 to WinXP. We do NOT support Vista.
Bram.
Bram van Kampen
|
|
|
|
|
Depending on the resolution and/or error range required, you could modify an NTP service to provide higher resolution time values, and have the client's hit it every so often to keep in sync.
If you need something really closer to Real-Time, there is a special kind of shared memory system that runs on a network using a special kind of NIC (I do not remember the name of the hardware/system). When this memory area is changed by one system, all other systems get an event. This is a pretty fast system, but might be overkill for you.
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Dont Quite understand Modifying NTP Services.
I have 6 Machines which over a week drift some 6 minutes apart. Nothing to cause a Problem as such, just a bit of a nuisance. I just wondered, has anyone a ready made piece of code you run in the scheduler, and which synchronises the clock in each machine with the Designated Timekeeper. It does not do an awfull lot for Absolute Time, but at least there's only one to adjust.
Regards
Bram van Kampen
|
|
|
|
|