|
He wanted to read data from notepad, not from a file.
An advice also:
fin>>data;
size = data.strlen();
name =(char*)malloc(size + 1);
streams (ifstream for example) are part of C++ and malloc is more a C programming style. In general, it is not really nice to mix C and C++ in this way. But this is just a detail .
|
|
|
|
|
hello,
thank you for the sudden response.
i know this is now mixing of C And C++.but how can i eliminate the problem.plz help me
thanks in advance
lekshmi
lekshmi
|
|
|
|
|
You've not been clear with your questions right from the beginning. Now what do you want to eliminate? You use VC++, but you don't wanna use C++, you want C rather? Anyway, If you want one from MFC, you can have a look at this.
<br />
CFile cf;<br />
cf.Open("c:\\test.txt",CFile::modeCreate|CFile::modeWrite);<br />
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[V]--
[My Current Status]
|
|
|
|
|
Sorry, I don't know the answer. I was just answering to another post.
|
|
|
|
|
Yes it is but i dont know any other way to do it. I think if it works, do it. Can you please tell me what could be the problems when we mix c and c++?
Thank you
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
Aqueel wrote: Yes it is but i dont know any other way to do it
Use new instead of malloc:
name = new char[size + 1];
For char arrays, there is no difference but if you use arrays of classes, then definitively you should use new instead of malloc. malloc will only allocate the memory and when you release it, it will just free the memory. With new and delete, the constructor and destructor of your class will be called which allows you to put some initialization and some clean-up code in your object. This is a much more object-oriented way of working.
Aqueel wrote: Can you please tell me what could be the problems when we mix c and c++?
There won't be any problems (or at least not that I'm aware of). It is more to have your code to be consistent. That's why I said it wan't very important .
|
|
|
|
|
Thank you Cedric!
I got it...
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
hi
Aqueel's code really works for me.but it is a mixing of both c and C++
how can i remove this.
i am using VC++6.0.is there a similar methods available in VC++
thanks in advance.
lekshmi
|
|
|
|
|
what do you want?
Menu:
1.Read A Text File.
2.Read The Text Content Of A NotePad.
3.Not Sure.
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[V]--
[My Current Status]
|
|
|
|
|
hello
i want to read the text content of a notepad
|
|
|
|
|
I tried with ::GetWindowText() with the help of Spy++ , but I could find Nothing visible. I'll try it again when I have enough time. But you'll certainly have a better answer from better coders here.
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[V]--
[My Current Status]
|
|
|
|
|
I don't know the answer but maybe I can help you to find another solution. What do you want to achieve exactly by reading the contents of notepad (this looks like a really strange idea and probably bad design). Please explain that as clearly as possible (not just "because I want to read that into my variables").
lekshmipriya wrote: is it necessary to use the database connection?
No notepad is not a database so this won't work at all.
|
|
|
|
|
I have a program (demo.exe) that I want get it in my web site and any one who down load it and unzip it in the computer , this program can run correctly even visual studio didn't install on that computer .
|
|
|
|
|
Please clearly explain your question.
Now i dont know what you actually want to do.
If you want your program to run on computers that do not have Visual studio installed on them, follow following instructions.
If you are using MS VC 6.0,
1 Open your project in MS VC++ compiler.
2. Go to Project and then Settings
3. Select Genral tab, Under Microsoft Foundation Class, select
Use MFC in a Static Library
4. Recompile your project.
Good luck
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
Aqueel wrote: 3. Select Genral tab, Under Microsoft Foundation Class, select
Use MFC in a Static Library
No mention was made of MFC.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
Well, in fact you didn't mention much.
I'll assume that what you want is:
1) Install the application in the web server
2) Make it possible for people to download it
3) Make it so people can run your application on their environment
To install the application in your web server you shouldn't need any special conditions. But, in fact, you don't say much about this. Do you host your web site? Did you make the site (HTML pages)?
Then, after clarifying what you want to do about point 1), you need to determine how people can reach your application. Installing the "demo.exe" file on a web page is not difficult, and if the users click on the link they will, typically, see a dialog box asking them if they want to execute or download the file.
If this were true for all people then point 2) above was not necessary, since the solution would be trivial. But the most recent operating systems have all kinds of firewalls and protection mechanisms that block executables, or make it much more difficult for people to download and execute them. Some antivirus programs that the user may have installed make it even more difficult to download your "demo.exe" and run it.
So, you may consider several options for your "demo.exe". The simplest one could be to wrap your application in a ZIP file, since these files are much more accessible. So, people would download "demo.zip", open it, and execute it. Although this makes it easier to get through some protections it is not full proof, and the user must have the ZIP (or UnZip) application installed on their system.
And there is also the corporate users. Anyone trying to download your application from within the company where they work will probably be blocked, even if you put the application inside a ZIP file. This will depend on the security policies of the company, and how strongly they enforce them.
Number 3) above concerns the client-side requirements. If you compile your application as "Release" then most Windows users can run your application, since all Windows contain most Release DLL's. If you distribute your program in Debug then the users may run into problems, since Debug DLL's are not, typically, included in Windows installations.
The above statement is not true for any .NET code. This code requires a virtual machine of about 22 MB to be installed in the client. Not all Windows installations have this, especially those before Windows XP. I'm not sure which have it and which do not, but you can google for this information. However, the statement is true for MFC applications, so you don't need to statically link. Your application is not MFC? Feel free to ignore the previous sentences...
Then, there is the problem of compatibility with very old operating systems, like Windows 95. This, of course, depends on the features your applications uses. For a simple dialog based GUI with some buttons you should be fine.
So, as you can see, your post provides very little (or no) information for a topic that is relativelly complex. You may want to ellaborate a little bit. Please take into account that downloading executables is considered to be the most dangerous way of spreading viruses, and people are becoming much more aware to that. I would, probably, not download your executable simple because it is an executable.
To get applications to run on the client machine after being downloaded from the WEB you should consider JAVA. It is not a hard language to learn, and it is considered much safer than executable binaries. So, the download and execution process become very simple.
|
|
|
|
|
Rilhas wrote: Well, in fact you didn't mention much.
You're right, other than my asking aquaal why he suggested statically linking with MFC even though akram made no mention of using MFC.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
Oh David! I am Aqueel, not Aquaal
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
My apologies. It was unintentional.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
thanks for your help
but I want to have an install program
when it install, all my Dll & ini files set in their directory
and then creat a shortcut to run my demo program.
tnks
|
|
|
|
|
My answer is applicable even if your "demo.exe" is an installation application. Installers like "msi" need extra care, but an "exe" installer is, for all intents and purposes, a directly executable application. So, all I said for executables applies.
However, some new information can be added, knowing that it is an installer. Typical problems with installers (especially custom made installers) is that they often forget people can have the operating system installed in different directories.
For example, the programs are installed in a "Program Files" directory when the Windows version is English, but are installed in a "Programas" directory when the Windows version is Portuguese. Other complications include additional drives: for example, I may have the operating system installed in drive C: and my programs installed in drive E:.
Depending on the installer you select for your application, you may want to use the following environment variables to make your installer as compatible as possible:
%HOMEPATH% (C:\Documents and Settings\Administrator)
%ALLUSERSPROFILE% (C:\Documents and Settings\All Users)
%SystemRoot% (C:\WINNT)
There are many more. Type "set" at a console prompt to see your defined environment variables.
To do that programatically, you can use standard ANSI code like:
#include <stdlib.h>
char* aup=getenv("ALLUSERSPROFILE")
Again, I sugest you provide more information on the details of your application.
Rogério
|
|
|
|
|
Sorry David! I don't know where was my mind. Next time i will be careful.
Thank you.
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
Which IDE are you using ? VC6, VC2003, VC2005, ... ? This is important because it is totaly different to deploy VC2005 applications.
|
|
|
|
|
I have a program (demo.exe) that I want get it in my web site and any one who down load it and unzip it in the computer , this program can run correctly even visual studio didn't install on that computer .
how can do that fast .
tnks
|
|
|
|
|
I answered your previous post: if it is C++ you need nothing special besides building the application in Release. Beware that .NET is not as easy.
For the C++ application to run on as many versions of Windows as possible (95, 98, Me, NT, 2000, XP) you should avoid using any "advanced features". The most simple applications (gialog based, or plain single-document like notepad) should then run on any of these OS versions if they are comiled in Release.
But you still don't provide much information about the executable. You already gave a hint that your program is not MFC. If it is not then Release builds will run on all sorts of machines with probably all OS versions. I have a VC2005 console release application compiled under Windows XP running on Windows 95 Intel 386@25MHz with 4 MB of RAM...
|
|
|
|