Assuming that a text file named FIRST.TXT contains some text written into it,
write a function named vowelwords( ), that reads the file FIRST.TXT and creates
a new file named SECOND.TXT, to contain only those words from the file
FIRST.TXT which start with a lowercase vowel (i.e. with ‘a’, ‘e’, ‘i’, ‘o’, ‘u’). For
example if the file FIRST.TXT contains
Carry umbrella and overcoat when it rains
Then the file SECOND.TXT shall contain
umbrella and overcoat it
A Function in Data File handling... C++?
I don't know how to inhibit the Yahoo software from
left justifying every line, so the lack of indentation
will make this hard to read. The code is really "C",
but it compiles and runs just fine under a C++ compiler.
Change the "fprintf(outfile" to "outfile%26lt;%26lt;" if you prefer.
In any case, "strtok" from the ANSI C library makes
this pretty straight-forward.
#include %26lt;stdio.h%26gt;
#include %26lt;string.h%26gt;
#include %26lt;stdlib.h%26gt;
int
main(int argc, char* argv[])
{
char buff[1000], *p, *t;
FILE *in = fopen("FIRST.TXT", "r");
FILE *out = fopen("SECOND.TXT", "w+");
if (!in || !out)
perror("fopen"), exit(-1);
while (fgets(buff, sizeof(buff), in)) {
p = buff;
while (t=strtok(p, " \t")) {
p = 0;
if (*t=='a' || *t=='e' || *t=='i' || *t=='o' || *t=='u')
fprintf(out, "%s ", t);
}
fprintf(out, "\n");
}
return 0;
}
Monday, May 24, 2010
I have a c++ program in a word file - how do i compile it using visual c++ 2005 express edition?
I dont know c++ that well. Someone wrote a program for me in put in a word file - How do I get it to work?
I have a c++ program in a word file - how do i compile it using visual c++ 2005 express edition?
You probably have to save it as a source file with the proper c++ extension for ms and then compile that file from the command line.
Reply:Beside it's content that you can see, a word document has a lot of metadata that is invisible to you but live there to make a document a word document. A C++ compiler won't understand those metadata and hence your pragram won't be compiled successfully at all. So all you have to do is to save the program in to a file with the extension of .cpp/.c and compile it afterwards.
Reply:just copy it from the file and paste it to VC++
wallflower
I have a c++ program in a word file - how do i compile it using visual c++ 2005 express edition?
You probably have to save it as a source file with the proper c++ extension for ms and then compile that file from the command line.
Reply:Beside it's content that you can see, a word document has a lot of metadata that is invisible to you but live there to make a document a word document. A C++ compiler won't understand those metadata and hence your pragram won't be compiled successfully at all. So all you have to do is to save the program in to a file with the extension of .cpp/.c and compile it afterwards.
Reply:just copy it from the file and paste it to VC++
wallflower
I have a trojan Horse Dropper.Generic.dtk in c:_restore\temp\A0020008.cpy file. How can I get it out?
when I go into the search and find the file it is in, C:_RESTORE\TEMP\A0020008.CPY, It will not let me delete it. I'm using AVG virus scan.
I have a trojan Horse Dropper.Generic.dtk in c:_restore\temp\A0020008.cpy file. How can I get it out?
Disable System Restore and Reboot (this will purge older system restore points). After rebooting, re-enable System Restore.
For reference, see the following from Bleeping Computer
Problems with System Restore
There are some problems associated with System Restore when it comes to viruses. When restore points are created they are stored in a directory that is accessible only to the System account and not to a user. This keeps the restore points safe from misuse and tampering. Unfortunately this also means that any virus scan software you may have installed can not scan the files located there as well. This causes a problem if a file that is infected with a virus gets backed up into a restore point because now the anti-virus software can not clean it. Now if you ever restore from a restore point, that file that is infected will be introduced back into your system.
With this in mind, if you find that you are infected with a virus, hijacker, or spyware and want to make sure you do not get reinfected if you restore a restore point, you should turn System Restore off and then back on again to clear all the restore points. This will guarantee that their are no infected files that could be restored.
Reply:The problem you have is your using a very poor AV - turn off system restore %26amp; in safe mode do a online scan:
http://www.bitdefender.com/scan8/ie.html
when computer clean turn system restore back on %26amp; get a good AV
Reply:scann your pc http://www.infectedornot.com and then downloading Ad-aware
Good Luck
I have a trojan Horse Dropper.Generic.dtk in c:_restore\temp\A0020008.cpy file. How can I get it out?
Disable System Restore and Reboot (this will purge older system restore points). After rebooting, re-enable System Restore.
For reference, see the following from Bleeping Computer
Problems with System Restore
There are some problems associated with System Restore when it comes to viruses. When restore points are created they are stored in a directory that is accessible only to the System account and not to a user. This keeps the restore points safe from misuse and tampering. Unfortunately this also means that any virus scan software you may have installed can not scan the files located there as well. This causes a problem if a file that is infected with a virus gets backed up into a restore point because now the anti-virus software can not clean it. Now if you ever restore from a restore point, that file that is infected will be introduced back into your system.
With this in mind, if you find that you are infected with a virus, hijacker, or spyware and want to make sure you do not get reinfected if you restore a restore point, you should turn System Restore off and then back on again to clear all the restore points. This will guarantee that their are no infected files that could be restored.
Reply:The problem you have is your using a very poor AV - turn off system restore %26amp; in safe mode do a online scan:
http://www.bitdefender.com/scan8/ie.html
when computer clean turn system restore back on %26amp; get a good AV
Reply:scann your pc http://www.infectedornot.com and then downloading Ad-aware
Good Luck
From where can i download a c++.exe file to install c++ in my comp?
Ho...Ho...Ho....Haven't you ever heard of a compiler in your life ??? C++ is not an .exe file, It is a language. To use the language, u have to download %26amp; install a compiler like Visual C++. Here is the link:
http://www.microsoft.com/express/vc/
From where can i download a c++.exe file to install c++ in my comp?
Yeah C++ isn't a program, it's a programming language meaning that you make your own programs, it's time consuming but it's fun and you can learn some cool things, I started with using Dev-C++ IDE at: http://www.bloodshed.net/devcpp.html and used this tutorial: http://www.cplusplus.com/doc/tutorial/ Like I said though, it won't be easy especially if you've never programmed before.
Reply:The previous link is for microsoft C++, which is far different from the ANSI C++(a C based language).
U can get Borland compiters.. Try to find that in google..
http://www.microsoft.com/express/vc/
From where can i download a c++.exe file to install c++ in my comp?
Yeah C++ isn't a program, it's a programming language meaning that you make your own programs, it's time consuming but it's fun and you can learn some cool things, I started with using Dev-C++ IDE at: http://www.bloodshed.net/devcpp.html and used this tutorial: http://www.cplusplus.com/doc/tutorial/ Like I said though, it won't be easy especially if you've never programmed before.
Reply:The previous link is for microsoft C++, which is far different from the ANSI C++(a C based language).
U can get Borland compiters.. Try to find that in google..
I am compiling a C++ builder file and i have some errors in include files.they dont include correctly.?
i need some one who knows how to help me to solve the prob.if there is any body may he/she tell me and i send her /him the errors or take his/her ID and ask her/him directly?
I am compiling a C++ builder file and i have some errors in include files.they dont include correctly.?
make sure you have the #include %26lt;WHATEVER%26gt; statements at the beginning. The "whatever" should be replaced with something like "stdio.h" or "math.h" depending on what libraries and include files you need.
Also make sure the include files are in the same directory you are working in.
Hard to help without more info. I'm certainly not an expert, but I have used C++ a bit.
I am compiling a C++ builder file and i have some errors in include files.they dont include correctly.?
make sure you have the #include %26lt;WHATEVER%26gt; statements at the beginning. The "whatever" should be replaced with something like "stdio.h" or "math.h" depending on what libraries and include files you need.
Also make sure the include files are in the same directory you are working in.
Hard to help without more info. I'm certainly not an expert, but I have used C++ a bit.
A c program to populate input file?
c++ program on laptop sales record.
Main menu:
Type A to populate input file
Type B to process data
Type C to print records
Type E to exit
Type Z to append function
A c program to populate input file?
what are you really asking for ?
hollyhock
Main menu:
Type A to populate input file
Type B to process data
Type C to print records
Type E to exit
Type Z to append function
A c program to populate input file?
what are you really asking for ?
hollyhock
Simple C++ source file and function problem?
I'm trying to create a simple program that prints the word "Hello" to the console. However, I want the program to use two different functions, the first being the main and the second being a void function that prints the word to the console. When I try to compile, it tells me there is an error at second2.h on the line that tries to print to the console (the line with cout). I was wondering what I did wrong.
Here is the code from main.cpp:
--------------------------------------...
include %26lt;cstdlib%26gt;
#include %26lt;iostream%26gt;
#include "second2.h"
using namespace std;
void sayHello();
int main(int argc, char *argv[])
{
sayHello();
system("PAUSE");
return EXIT_SUCCESS;
}
--------------------------------------...
the code from second2.h:
--------------------------------------...
#include %26lt;cstdlib%26gt;
#include %26lt;iostream%26gt;
void sayHello()
{
cout %26lt;%26lt; "Hello" %26lt;%26lt; endl;
}
--------------------------------------...
Thanks.
Simple C++ source file and function problem?
Just a guess:
Try moving the using namespace std; before the #include "second2.h", which, as someone else has pointed out, shouldn't include the sayHello() function definition, just its declaration.
I'm thinking your compiler requires the namespace be already pulled in for cout, which, as your code is currently configured, it isn't when sayHello() is compiled.
Good luck.
By the way, any compiler that just says there's an error on line such-and-such without giving any details should be evicted from your machine..
Reply:It cant compile, first line should be #include... and not include...
you should not declare sayHello in the cpp file it is already included in second2.h
I hope EXIT_SUCCESS is defined I don't use this macro.
Reply:You do have a compiler issue (your exact program compiles with Borland for example with the extra # for include first line) but you should be able to compile this with more rigid code.
Function declarations should be in header files so that other .c files can see them without explicitly extern-ing them.
Function definitions should always be in .c files.
That will suit all compilers.
So second2.h should just have
extern void sayHello();
Ths means there is a single place where the function is extern-ed and made available to other files.
Your main file
void sayHello()
{
cout %26lt;%26lt; "Hello" %26lt;%26lt; endl;
}
int main(int argc, char *argv[])
{
sayHello();
system("PAUSE");
return EXIT_SUCCESS;
}
If no other file requires the sayHello function then it ought to be declared as static in the same file as the function definition.
Reply:--- main.cpp ---
#include %26lt;iostream%26gt;
#include "2nd.h"
int main()
{
hello();
system("PAUSE");
}
--- 2nd.h ---
#include %26lt;iostream%26gt;
using namespace std;
void hello()
{
cout %26lt;%26lt; "Hello World!\n";
}
Here is the code from main.cpp:
--------------------------------------...
include %26lt;cstdlib%26gt;
#include %26lt;iostream%26gt;
#include "second2.h"
using namespace std;
void sayHello();
int main(int argc, char *argv[])
{
sayHello();
system("PAUSE");
return EXIT_SUCCESS;
}
--------------------------------------...
the code from second2.h:
--------------------------------------...
#include %26lt;cstdlib%26gt;
#include %26lt;iostream%26gt;
void sayHello()
{
cout %26lt;%26lt; "Hello" %26lt;%26lt; endl;
}
--------------------------------------...
Thanks.
Simple C++ source file and function problem?
Just a guess:
Try moving the using namespace std; before the #include "second2.h", which, as someone else has pointed out, shouldn't include the sayHello() function definition, just its declaration.
I'm thinking your compiler requires the namespace be already pulled in for cout, which, as your code is currently configured, it isn't when sayHello() is compiled.
Good luck.
By the way, any compiler that just says there's an error on line such-and-such without giving any details should be evicted from your machine..
Reply:It cant compile, first line should be #include... and not include...
you should not declare sayHello in the cpp file it is already included in second2.h
I hope EXIT_SUCCESS is defined I don't use this macro.
Reply:You do have a compiler issue (your exact program compiles with Borland for example with the extra # for include first line) but you should be able to compile this with more rigid code.
Function declarations should be in header files so that other .c files can see them without explicitly extern-ing them.
Function definitions should always be in .c files.
That will suit all compilers.
So second2.h should just have
extern void sayHello();
Ths means there is a single place where the function is extern-ed and made available to other files.
Your main file
void sayHello()
{
cout %26lt;%26lt; "Hello" %26lt;%26lt; endl;
}
int main(int argc, char *argv[])
{
sayHello();
system("PAUSE");
return EXIT_SUCCESS;
}
If no other file requires the sayHello function then it ought to be declared as static in the same file as the function definition.
Reply:--- main.cpp ---
#include %26lt;iostream%26gt;
#include "2nd.h"
int main()
{
hello();
system("PAUSE");
}
--- 2nd.h ---
#include %26lt;iostream%26gt;
using namespace std;
void hello()
{
cout %26lt;%26lt; "Hello World!\n";
}
Subscribe to:
Posts (Atom)