|
I agree with Christian .. best you could do is memory map the file and read it and write it to another file starting from a x byte offset into the file (where x can be your 50) etc .. you can optimise the read/write buffers etc although windows should do a good job for you, especially if you memory map it ..
'G'
|
|
|
|
|
They're both right (accept Christian ment bytes not bits).
Here's a couple of old fashion ways (still apply):
// Slow
1) Read byte 50+i. // where i starts at 0.
2) Copy byte 50+i to byte i.
3) Repeat 1 and 2, util you reach the end of the file.
4) Set file size to the original size - 50.
// Faster
1) Open a temporary file.
2) Copy all the bytes, starting at byte 50, from original file to the temporary file.
3) Delete the original file.
4) Rename the temporary file to the origninal files name.
// THIS FITS BETTER (given enough memory)
1) Read the entire (original) file into memory.
2) Copy the data back to the file starting with byte 50.
(no memcpy or memmove required).
3) Set file size to the original size - 50.
Use your imagination, there are other ways. Even if there was a function call to do this for you, it would still do it the same way.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Below is apart of my program:
else
{
SktAddr.sin_family=AF_INET;
SktAddr.sin_port=htons(ReadPortNo("[TCP.FLDATA.SRV.COMMUNICATION]"));
SktAddr.sin_addr.s_addr=htonl(INADDR_ANY)
But it have the error below:
error C2227: left of '.sin_family' must point to class/struct/union
error C2227: left of '.sin_port' must point to class/struct/union
error C2227: left of '.sin_addr' must point to class/struct/union
error C2227: left of '.s_addr' must point to class/struct/union
Can teach me how to solve these problem.....
|
|
|
|
|
1983ttj wrote:
SktAddr.sin_family=AF_INET;
Is SktAddr a class, or an instance of a class ? If it's a class, make an instance, and if it's an instance, include the header to tell this code what it means.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
how to know that SktAddr is a class? how to make an instance?
|
|
|
|
|
1983ttj wrote:
how to know that SktAddr is a class?
Well, if it's not an instance, it's a class.
A class definition looks like this
class MyClass
{
/....
An instance looks like this
MyClass myClass;
The capitalisation is not important, except in that the language is case sensitive. That is, an instance can start with a capital, and a class with lowercase.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have a dialog and only got one start button. I do some program about ListenThread and got around 4 errors. All of the errors is about undefined identifier.I don't know how and where to declare it. In the Dlg.h file?
Below is apart of my code:
UINT ListenThread(LPVOID lParam)
{
char szMessage[300];
wsprintf(szMessage, "(ListenThread) - Starting TCP/IP Initialisations.");
//WriteSysLog(szMessage);
ServerSkt = socket ( AF_INET, SOCK_STREAM, 0 );
return 0;
}
I have header files as shown below:
Resource.h
StdAfx.h
TCPTest.h
TCPTeseDlg.h
and the errors are below
error C2065: 'ServerSkt' : undeclared identifier
error C2065: 'socket' : undeclared identifier
error C2065: 'AF_INET' : undeclared identifier
error C2065: 'SOCK_STREAM' : undeclared identifier
Error executing cl.exe.
where should I declare ?
-- modified at 0:09 Wednesday 31st August, 2005
|
|
|
|
|
What is SktAddr ? Is it a class ? Is it an instance of a class ? Is it something you copied out of a book and you have no idea what it is ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I was given a source code from my supervisor and the source code have around three thousand of line. He want me to break some of the source code into a simple program. So I designed a dialog with a start button and try some part of the source code that my supervisor gave me. And I actually not good in programming so the program got alot of error that I don't know how to solve it.
|
|
|
|
|
That just doesn't work. A large program is littered with dependancies. Your supervisor needs a smack in the head.
1983ttj wrote:
And I actually not good in programming so the program got alot of error that I don't know how to solve it.
I can't believe how many people who are 'not good at programming' are being paid to do it, and left to sink or swim by their supervisors. Buy a book and learn in your own time, then find a better job. Or, just find another job. Seriously. I can't give more specific advice based on what you posted, except to say that you're lost at sea. Ask specific questions, and I'll be glad to help you.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
-- modified at 4:47 Wednesday 31st August, 2005u create the the application usingDialog based using AppWizard then chooose Windows Socket option it will automatically add #include afxsock.h .u can check it in stdafx.h
|
|
|
|
|
u create the the Dialog based application using AppWizard then chooose Windows Socket option it will automatically add #include <afxsock.h>.u can check it in stdafx.h
|
|
|
|
|
1983ttj wrote:
error C2227: left of '.sin_family' must point to class/struct/union
Do u forget to include afxsock.h/winsock2.h header file in your project....+ also link your project with ws2_32.lib to save project from linker error too.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
We know that you can add a new tab view when you want to add a new source file in visual.net
I also want to do like that.
Could you give me some free example.
Thanks a lot! I do hope you could give me a hand
|
|
|
|
|
The tab control is a basic control, available to any MFC app.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks for you reply,but I mean that I want a tabbed view not tab control
And i want a example programme because i am a green hand
Jack
|
|
|
|
|
Searching[^] this very site gave me a number of hits.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello again guys.
Ok, here's my project situation.
My project launch an application that shows an html page contain japanese letters/characters from the created file. Before the html page launch, there's a hidden process that the html page to be launch is created. I successfully did this process except when the application launch, the html displays unformatted character encoding. I check the html file that has been created and open it in an editor, I see no problem with the html file. In html file, the character set is "euc-jp". But I wonder why, when the application launch, html page displays different from it should be. I wonder if there's any character encoding rule in writing into a file. I only used the fopen and fwrite function for writing html code in a file.
I would like to ask if someone knows about character set encoding in writing to a file. Any help is much appreciated.
Thanks a lot guys out there.
With great power comes a great responsibility.
|
|
|
|
|
|
Thanks for the link. I just convert the string I need to write in an html(from CString to BSTR), and it displays correctly. Though when I open the html file in an editor, it didn't display correctly. Anyway, that's not a big deal. I hope it will display correctly if I open it with Dreamweaver.
Thank you all cp guys. You really help a lot someone like us (beginners in C++/MFC).
More power!
With great power comes a great responsibility.
|
|
|
|
|
Ok. I thought it's ok now, but still not.. I noticed that when the application launch, it display what html file content before an overwriting file process. So this is now my problem, how can I do that the html to be display is the new created one?
Also, when I try to execute the .exe file, it says abnormal program termination. I try to debug, and it detects that a memory leaks happened. I don't know how I will debug this. Another one is several DLL files- no matching symbolic information found. I am really confused with this, I thought it's already ok then suddenly it's not...
With great power comes a great responsibility.
|
|
|
|
|
My project still won't build. I get these two errors:
nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv
nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc
My project statically links to MFC, as otherwise I get a million other errors trying to link to a library we use. It explicitly ignores libcmt.lib, as otherwise it clashes with msvcrt.lib. Any help at all will be greatly appreciated.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Are you compiling with /MD set ? You need to if you want to link with msvcrt.lib. I ask because I seem to remember that you said you used /MT and that causes linking with libcmt.lib.
|
|
|
|
|
OK - I have to compile with /MT because otherwise I can't link to an external library I am using. I am explicitly excluding libcmt from my lib list, but if I exclude msvcrt, I get more errors. Does this mean I am still linking with some libraries that use /MD ?
Christian Graus - Microsoft MVP - C++
|
|
|
|