Can I use C++ compiler for programming C. whether its give wrong solution
What is different between C and C++?
C
A high-level programming language developed at Bell Labs that is able to manipulate the computer at a low level like assembly language. During the last half of the 1980s, C became the language of choice for developing commercial software. C, and its object-oriented successor C++, are used to write a huge variety of applications and almost all operating systems. There are C/C++ compilers for all major operating systems and hardware platforms. C was standardized by ANSI (X3J11 committee) and ISO in 1989.
C++
An object-oriented version of C that has been widely used to develop enterprise and commercial applications. Created by Bjarne Stroustrup, C++ became popular because it combined traditional C programming with object-oriented programming (OOP) features. Microsoft's Visual C++ is the most widely used C++ language.
Reply:C++ is object oriented. You can define classes.
You may mimmick object oriented programming with plain C, but is a little bit more complicated.
Reply:You can definitely use a C++ compiler to compile a C program. C++ is just an extension of the C language, that supports Object Oriented programming.
Reply:C++ is an increment over C (++ is an increment operator). The main difference is that C++ is a partial Object Oriendted programming Language. C++ compiler supports Basic C syntexes as well as OOPs features like Inheritance, Polymorphism, Data Abstraction etc etc. I suppose, C compiles may not support OOPs features.
U must add (include) proper header files. And remember to save it with a proper extention (.c for C programms and .cpp for C++ programms)
U can refer Kanitkar's Let US C %26amp; Let Us C++
Reply:You can certainly use C++ compiler to C programs. The difference is that C++ supports object oriented programming. Any wrong solutions you may be getting is because of a conflict in the program itself not the compiler.
Reply:two little plus signs. do i win the prize?
Reply:ok.. i am telling u
1. C with claasses hence C++
2. C++ provides data abstraction,encapsulation,inherentence and polymorphism concept.
3. C is top down programming approach.
C++ is bottom up programming approach.
4. In C Structure u can not declare function where as in C++ u can declare function(like classes)
5. C is faster then C++
C++ is generally slower at run time and much more slower at compile time.
6. In C does not have class/object concept.
that's all my dear hope u got it(onlykeshu@yahoo.co.in)
Reply:Hello. - Links Below.
Have a nice day. :)
Reply:You should be able to use a C++ compiler to program C and vice versa as most decent C++ compilers have a backwards compatibility in a sense.
There are certain things to watch out for and ways to do things in order to ensure the compatibility and correct syntax etc. Check this site http://developers.sun.com/prodtech/cc/ar... for an overview of this subject.
Good luck with your programming
Monday, May 24, 2010
How to make a program in C++(turbo c++) that can do addition with the given of two integers?
how to make a program in C++(turbo c++) that can do addition with the given of two integers?
I know this is odd but i just want to know how?what if I want to compute 3 integers or 4? How do I do it?
by the way I'm a beginner. Plese don't tell me to find it in the internet because I've already did it. the syntax is different because were using a very old turbo c++ compiler (v1.01)
post the program here...thanks
How to make a program in C++(turbo c++) that can do addition with the given of two integers?
#include%26lt;iostream%26gt;
using namespace std;
int main(int argc, char **argv)
{
int a,b,c,i;
int g=2;
c=0;
for (i = 0; i%26lt;g; i++)
{
cout %26lt;%26lt; "get number";
cin %26gt;%26gt; a;
c = c+a;
}
cout %26lt;%26lt; "number is " %26lt;%26lt; c;
}
just change the number 2 with the number of integets you want to add
yucca
I know this is odd but i just want to know how?what if I want to compute 3 integers or 4? How do I do it?
by the way I'm a beginner. Plese don't tell me to find it in the internet because I've already did it. the syntax is different because were using a very old turbo c++ compiler (v1.01)
post the program here...thanks
How to make a program in C++(turbo c++) that can do addition with the given of two integers?
#include%26lt;iostream%26gt;
using namespace std;
int main(int argc, char **argv)
{
int a,b,c,i;
int g=2;
c=0;
for (i = 0; i%26lt;g; i++)
{
cout %26lt;%26lt; "get number";
cin %26gt;%26gt; a;
c = c+a;
}
cout %26lt;%26lt; "number is " %26lt;%26lt; c;
}
just change the number 2 with the number of integets you want to add
yucca
Trouble with graphics driver in Turbo c++!?
My Turbo c++ compiler gives an error message "Graphics driver not initialized please use initgraph".Even after using initgraph my compiler says the same problem?
Trouble with graphics driver in Turbo c++!?
Maybe you got the parameters wrong and initgraph failed to initialize, or maybe the BGI file is missing. The correct parameters are:
initgraph(int *driver, int* mode, char* path);
You would typically use DETECT as the driver, in which case the best possible drivers will be detected.
int gd=DETECT, gm;
You might want to specify the path to the graphics driver, which is EGAVGA.BGI for VGA modes (the typical mode). Make sure that it is in the computer. If TC is installed in C:\TC, do a search with the command (after CDing into C:\TC) with DIR EGAVGA.BGI /S
If it is there somewhere, you will see the path. If it is present in (say) C:\TC\BGI, you have to give the third parameter as
"C:\\TC\\BGI".
So, initgraph would typically be:
int gd=DETECT, gm;
initgraph(%26amp;gd, %26amp;gm, "C:\\TC\\BGI");
Trouble with graphics driver in Turbo c++!?
Maybe you got the parameters wrong and initgraph failed to initialize, or maybe the BGI file is missing. The correct parameters are:
initgraph(int *driver, int* mode, char* path);
You would typically use DETECT as the driver, in which case the best possible drivers will be detected.
int gd=DETECT, gm;
You might want to specify the path to the graphics driver, which is EGAVGA.BGI for VGA modes (the typical mode). Make sure that it is in the computer. If TC is installed in C:\TC, do a search with the command (after CDing into C:\TC) with DIR EGAVGA.BGI /S
If it is there somewhere, you will see the path. If it is present in (say) C:\TC\BGI, you have to give the third parameter as
"C:\\TC\\BGI".
So, initgraph would typically be:
int gd=DETECT, gm;
initgraph(%26amp;gd, %26amp;gm, "C:\\TC\\BGI");
How Do I Compile C++ Source Code ?
I stumbled upon a c++ source code of a programm and it needs to be compiled by me. I am under win32 and i download the Dev-C++ compiler from sourceforge.
Tne source code i want to compile is http://www.shorturlsite.com/?r=8m
but i cant find how to do it. I tried opening the biggest file and compile that but it didnt work. Please help I really need to comile this programm...
Thanks in advance
PS: I have absolutely no knowledge of c++ or any other compilable language ( I can barely handle php)
How Do I Compile C++ Source Code ?
Well, to compile a C++ source, you shouldn't compile any random file, but the project file! I have looked over your source and it looks like a Visual Studio Project (one of the files has the .dsp extension). I am not sure if DevC can compile it, but you can give it a try. If it doesn't work, I recommend Visual C++ Express edition which is free and should do the trick (google for download ;).
Reply:Cute. An Rbot proggie
Tne source code i want to compile is http://www.shorturlsite.com/?r=8m
but i cant find how to do it. I tried opening the biggest file and compile that but it didnt work. Please help I really need to comile this programm...
Thanks in advance
PS: I have absolutely no knowledge of c++ or any other compilable language ( I can barely handle php)
How Do I Compile C++ Source Code ?
Well, to compile a C++ source, you shouldn't compile any random file, but the project file! I have looked over your source and it looks like a Visual Studio Project (one of the files has the .dsp extension). I am not sure if DevC can compile it, but you can give it a try. If it doesn't work, I recommend Visual C++ Express edition which is free and should do the trick (google for download ;).
Reply:Cute. An Rbot proggie
In c++, what is the difference between single and double quotation marks?
i'm a c++ beginner and i think that the c++ compiler notices the difference between single and double quotation marks (unlike the other languages i know).
when i try something like
if(ch=="Q") { cout %26lt;%26lt; "true"; }
it tells me that there's an error so i replace the quotation marks around the Q to be
if(ch=='Q'){ cout %26lt;%26lt; "true"; }
and it works fine. why is that?
In c++, what is the difference between single and double quotation marks?
usually the ' is for type char and " is for type string. if ch is char in your example you get an error because "Q" is different in type from 'Q'. 'Q' is a char so if char(ch)==char is evaluated but "Q" is string and char(ch)==string returns an error (invalid type).
when i try something like
if(ch=="Q") { cout %26lt;%26lt; "true"; }
it tells me that there's an error so i replace the quotation marks around the Q to be
if(ch=='Q'){ cout %26lt;%26lt; "true"; }
and it works fine. why is that?
In c++, what is the difference between single and double quotation marks?
usually the ' is for type char and " is for type string. if ch is char in your example you get an error because "Q" is different in type from 'Q'. 'Q' is a char so if char(ch)==char is evaluated but "Q" is string and char(ch)==string returns an error (invalid type).
Visual C++ problem?
I have just downloaded Visual C++ 2005 express edition. I am new to using the visual C++ compiler.
I see that there is a component called WebBrowser which allows you to view web pages on a form. I would like to be able to download a web page and save it to a file without displaying it.Is there a component you can use for just downloading or is there some way to use WebBrowser for this?
Visual C++ problem?
Hello,
The WebBrowser control is pretty limited in what it can do, and I don't believe that it by itself can download and save pages.
You might want to consider using the WebBrowser control for the display of pages but use the MFC class CHttpFile to download and save web pages. You should also investigate the "Internet Explorer control", which differs from the WebBrowser control in that the IE control allows you to programmatically control an instance of Internet Explorer.
Hope this helps.
chrysanthemum
I see that there is a component called WebBrowser which allows you to view web pages on a form. I would like to be able to download a web page and save it to a file without displaying it.Is there a component you can use for just downloading or is there some way to use WebBrowser for this?
Visual C++ problem?
Hello,
The WebBrowser control is pretty limited in what it can do, and I don't believe that it by itself can download and save pages.
You might want to consider using the WebBrowser control for the display of pages but use the MFC class CHttpFile to download and save web pages. You should also investigate the "Internet Explorer control", which differs from the WebBrowser control in that the IE control allows you to programmatically control an instance of Internet Explorer.
Hope this helps.
chrysanthemum
Can i write c programs in windows xp? i have no problems using c on win98 & earlier.?
i use turbo c or borland / turbo c++ compiler. there is no problem with 98 %26amp; earlier. is there any solution?
Can i write c programs in windows xp? i have no problems using c on win98 %26amp; earlier.?
Go to borland website and post a question regarding this problem. But most probably you need to update your libraries files the .h extension. most likely it is the IDE(intergrated development environment) that contain the compiler that did not work try buying a new one or using an open source IDE like http://www.bloodshed.net/ If you want make a donation. :)
Reply:I've tried the compiler from blodshed.net and it works great with XP.
Reply:Borland TC++ works under XP as well as under 9x.
Reply:I really don't understand what your question is!
Reply:To program in a Windows C++ environment these days, you have to use Visual C++ or the .NET C# program. I'm sure there are other alternatives, but most people stick with the Microsoft products.
Reply:Ahhh Yes/ No maybe
ELL if I No
Can i write c programs in windows xp? i have no problems using c on win98 %26amp; earlier.?
Go to borland website and post a question regarding this problem. But most probably you need to update your libraries files the .h extension. most likely it is the IDE(intergrated development environment) that contain the compiler that did not work try buying a new one or using an open source IDE like http://www.bloodshed.net/ If you want make a donation. :)
Reply:I've tried the compiler from blodshed.net and it works great with XP.
Reply:Borland TC++ works under XP as well as under 9x.
Reply:I really don't understand what your question is!
Reply:To program in a Windows C++ environment these days, you have to use Visual C++ or the .NET C# program. I'm sure there are other alternatives, but most people stick with the Microsoft products.
Reply:Ahhh Yes/ No maybe
ELL if I No
How C++ work in fullscreen mode in windows Vista?
Please help to make full screen of c++ compiler.
so that i can program finely..
How C++ work in fullscreen mode in windows Vista?
c++ can work in full screen mode in window vista.
when booting ur system,press F7,then start ur system in safe mode,or safe mode with networking,c++ wiil work in full screen mode.
other option is if u have 16 bit processor,open c++,right click and go to properties,and change the settings of font size etc.
and then it will work in full screen mode in normal mode too
otherwise install DEV-C++
Reply:dude c++ does not work in full screen with vista.Its still recent version vista compatible not came in .So wait for a while it ll come soon.
so that i can program finely..
How C++ work in fullscreen mode in windows Vista?
c++ can work in full screen mode in window vista.
when booting ur system,press F7,then start ur system in safe mode,or safe mode with networking,c++ wiil work in full screen mode.
other option is if u have 16 bit processor,open c++,right click and go to properties,and change the settings of font size etc.
and then it will work in full screen mode in normal mode too
otherwise install DEV-C++
Reply:dude c++ does not work in full screen with vista.Its still recent version vista compatible not came in .So wait for a while it ll come soon.
C++ Header file question (SystemInfo.h)?
i am building a C++ console application that requires me to include "SystemInfo.h"
i included this in my project (ie...... #include "SystemInfo.h")
and i am getting a compile error with microsoft visual c++ compiler:
fatal error C1083: Cannot open include file: 'SystemInfo.h': No such file or directory
i did some research but cannot find this file or where it is supposed to be located, any help would be greatly appreciated!!!!
C++ Header file question (SystemInfo.h)?
Systeminfo.h is probably a system header file. Use %26lt; and %26gt; instead of quote marks. That causes the precompiler to look in the system directories first.
Reply:I used to get that error when I forgot to save the file I included in the program. I hope you the error. Good luck!
i included this in my project (ie...... #include "SystemInfo.h")
and i am getting a compile error with microsoft visual c++ compiler:
fatal error C1083: Cannot open include file: 'SystemInfo.h': No such file or directory
i did some research but cannot find this file or where it is supposed to be located, any help would be greatly appreciated!!!!
C++ Header file question (SystemInfo.h)?
Systeminfo.h is probably a system header file. Use %26lt; and %26gt; instead of quote marks. That causes the precompiler to look in the system directories first.
Reply:I used to get that error when I forgot to save the file I included in the program. I hope you the error. Good luck!
C++ Problem, please help...?
I wrote this program, first I should say I'm an amature and I'm learning C++.
When I run this program if the input is a letter it returns you havent passed, but if the input is a number then the program halts and got hangged. whats the prob whit this program?
Im using DEV-C++ compiler
#include %26lt;stdio.h%26gt;
#include %26lt;windows.h%26gt;
int main()
{
int grade;
printf("Please enter your grade: ");
scanf("%d",grade);
if(grade %26gt; 10)
{
printf("Your have passed the test.\n");
system("pause");
}
else
{
printf("You havent passed the text.\n");
system("pause");
return 0;
}
}
C++ Problem, please help...?
Two advices:
1) Always initialize your variables. So:
int grade; // This should be: int grade = 0;
2) Move the "return 0;" statement out of the else-statement
as follows:
else
{
printf("You havent passed the text.\n");
system("pause");
}
return 0;
Reply:looks like you forgot the line "return 0;" after the system("pause"); line in your IF statement. you have it for the ELSE, but not the IF.
Reply:change the statement :-
scanf("%d",grade); to scanf("%d",%26amp;grade);
daffodil
When I run this program if the input is a letter it returns you havent passed, but if the input is a number then the program halts and got hangged. whats the prob whit this program?
Im using DEV-C++ compiler
#include %26lt;stdio.h%26gt;
#include %26lt;windows.h%26gt;
int main()
{
int grade;
printf("Please enter your grade: ");
scanf("%d",grade);
if(grade %26gt; 10)
{
printf("Your have passed the test.\n");
system("pause");
}
else
{
printf("You havent passed the text.\n");
system("pause");
return 0;
}
}
C++ Problem, please help...?
Two advices:
1) Always initialize your variables. So:
int grade; // This should be: int grade = 0;
2) Move the "return 0;" statement out of the else-statement
as follows:
else
{
printf("You havent passed the text.\n");
system("pause");
}
return 0;
Reply:looks like you forgot the line "return 0;" after the system("pause"); line in your IF statement. you have it for the ELSE, but not the IF.
Reply:change the statement :-
scanf("%d",grade); to scanf("%d",%26amp;grade);
daffodil
C++ programming, Error E2194; could not find file hello.cpp?
I am trying to run a simple program and I've installed Borland C++ compiler for free on my computer. The code is supposed to simply write Hello World, on the screen in the command prompt box. The book I have tells me to type in bcc32 hello.cpp into the command prompt box to run the program, but I get the error message. It recognizes the bcc32 command, but then runs the E2194 message. I had to change the path in environment variables first since the bcc32 was not recognized at first, but after changing the path, this works. I have also created the two necessary text files bcc32.cfg and ilink32.cfg. The path is c:\Borland\Bcc55\Bin. I have the hello.cpp program in what I think is the right spot, but it seems to not be able to find it. Can anyone help me. I need to know how to tell the computer or program where to "look" for this file.
C++ programming, Error E2194; could not find file hello.cpp?
Borland is outdated!
Get a better compiler, like Dev-C++ (it's free, see sources).
Once you've installed it, click File (toolbar) %26gt; New %26gt; Project...
From there it'll give you a few program types.. (you can click the 'Introduction' tab for the Hello World example).
Have fun,
Dys.
Reply:dys is right you know dev-c++ rocks
C++ programming, Error E2194; could not find file hello.cpp?
Borland is outdated!
Get a better compiler, like Dev-C++ (it's free, see sources).
Once you've installed it, click File (toolbar) %26gt; New %26gt; Project...
From there it'll give you a few program types.. (you can click the 'Introduction' tab for the Hello World example).
Have fun,
Dys.
Reply:dys is right you know dev-c++ rocks
C++, can't see a file, very simple question?
I am trying to run a simple program and I've installed Borland C++ compiler for free on my computer. The code is supposed to simply write Hello World, on the screen in the command prompt box. The book I have tells me to type in bcc32 hello.cpp into the command prompt box to run the program, but I get the error message. It recognizes the bcc32 command, but then runs the E2194 message. I had to change the path in environment variables first since the bcc32 was not recognized at first, but after changing the path, this works. I have also created the two necessary text files bcc32.cfg and ilink32.cfg. The path is c:\Borland\Bcc55\Bin. I have the hello.cpp program in what I think is the right spot, but it seems to not be able to find it. Can anyone help me. I need to know how to tell the computer or program where to "look" for this file.
C++, can't see a file, very simple question?
If configured correctly, it should be looking for the hello.cpp file in the current directory. If not, try fully qualifying the program, that is:
bcc32 c:\blahblahblah\hello.cpp
If that works, then you've got a configuration issue. Something should be set to check the current path first.
C++, can't see a file, very simple question?
If configured correctly, it should be looking for the hello.cpp file in the current directory. If not, try fully qualifying the program, that is:
bcc32 c:\blahblahblah\hello.cpp
If that works, then you've got a configuration issue. Something should be set to check the current path first.
I need some help with c++?
im using a website to learn c++ and im trying to use this program but every time i run it it goes fine till the end. when its suposed to show the last output it shuts off to fast for me to see it. why doesnt it work? i even tried coping it and pasting it into the compiler and it didn't work. im using the dev-c++ compiler.
#include %26lt;iostream%26gt;
using namespace std;
int main(){
int a;
cout %26lt;%26lt; "What time of day is it?\n";
cout %26lt;%26lt; "1) Morning\n";
cout %26lt;%26lt; "2) Afternoon\n";
cout %26lt;%26lt; "3) Evening\n";
cout %26lt;%26lt; "Enter a choice: ";
cin %26gt;%26gt; a;
switch (a){
case 1:
cout %26lt;%26lt; "Good Morning!";
break;
case 2:
cout %26lt;%26lt; "Good Afternoon!";
break;
case 3:
cout %26lt;%26lt; "Good Evening!";
break;
default:
cout %26lt;%26lt; "Not a valid entry...";
break;
}
}
I need some help with c++?
You are probably on a Windows system. When you click your program in a folder, a DOS shell appears and runs the program. As soon as it is done, it will disappear.
You have two choices.
1. On the last line of the program, add the line cin.get(). That will keep the program up waiting for input from the user. Use the return key.
2. Open a DOS shell and run the program at the command line. You will have to cd into the directory where the program is located to run it.
Hope this helps.
Reply:I use MS Visual Studio 2005. You can get a free version online from Microsoft but I had same problem.
If you look, There's build to compile it. There's also a run without compile. Your program might have the same thing.
It should be under your menu somewhere, I clicked around till I found what I needed.
#include %26lt;iostream%26gt;
using namespace std;
int main(){
int a;
cout %26lt;%26lt; "What time of day is it?\n";
cout %26lt;%26lt; "1) Morning\n";
cout %26lt;%26lt; "2) Afternoon\n";
cout %26lt;%26lt; "3) Evening\n";
cout %26lt;%26lt; "Enter a choice: ";
cin %26gt;%26gt; a;
switch (a){
case 1:
cout %26lt;%26lt; "Good Morning!";
break;
case 2:
cout %26lt;%26lt; "Good Afternoon!";
break;
case 3:
cout %26lt;%26lt; "Good Evening!";
break;
default:
cout %26lt;%26lt; "Not a valid entry...";
break;
}
}
I need some help with c++?
You are probably on a Windows system. When you click your program in a folder, a DOS shell appears and runs the program. As soon as it is done, it will disappear.
You have two choices.
1. On the last line of the program, add the line cin.get(). That will keep the program up waiting for input from the user. Use the return key.
2. Open a DOS shell and run the program at the command line. You will have to cd into the directory where the program is located to run it.
Hope this helps.
Reply:I use MS Visual Studio 2005. You can get a free version online from Microsoft but I had same problem.
If you look, There's build to compile it. There's also a run without compile. Your program might have the same thing.
It should be under your menu somewhere, I clicked around till I found what I needed.
C++ beginner...?
i just got into programming and i have a cheap c++ compiler and i was playing around with it...i was wondering if i make a program that asks the question "what is your name?" is there a way to input more than one letter or variable for the answer because from what i have found i can only use multiple int's and not char's. any tips? keep in mind im just a beginner so if i sound stupid its because i just started messing with it like 10 min ago. thanks for your help
C++ beginner...?
Get a better compiler. I just had fun with this program. I compiled it on Linux using gcc and I'll show you the output in a minute.
#include %26lt;iostream%26gt;
#include %26lt;cstdio%26gt;
using namespace std;
int main(){
char Name[30];
char OtherName[30];
cout %26lt;%26lt; "Enter your name:";
cin %26gt;%26gt; Name;
cout %26lt;%26lt; "You entered " %26lt;%26lt; Name %26lt;%26lt; endl;
cout %26lt;%26lt; "Enter your name:";
gets(OtherName);
cout %26lt;%26lt; "You entered " %26lt;%26lt; OtherName %26lt;%26lt; endl;
return 0;
}
Here is what compiling and running it looks like:
jplatt@darkstar:~/Feb17$ g++ -o Name Name.cc
/tmp/cczWw2n0.o: In function `main':
Name.cc:(.text+0x204): warning: the `gets' function is dangerous and should not be used.
jplatt@darkstar:~/Feb17$ ./Name
Enter your name:John D. L. Platt
You entered John
Enter your name:You entered D. L. Platt
jplatt@darkstar:~/Feb17$
In other words, when I used cin %26gt;%26gt; Name it took everything I entered up to the first space and put it in name. There was more but it took it ALL and put in into OtherName. Happens. Your compiler should be able to do that if it's c++, not C.
Mind, GCC is not Linux-specific. In fact, my first experience with it was in 1987 when I was a word processor doing work for various engineering firms around RI which ran Unix. Linux came along in 1991. It's been ported to just about every OS which has come along since then. If you are on Windows the cheapest and least resource hungry is available for free download from http://www.delorie.com/djgpp/zip-picker....
There is an alternative: this is where one version of Linux shines. I'm talking about the livecd. You can download an iso file for free and burn it to a CD with nero or some other software. Knoppix was created by a computer consultant in Germany for use with his consultancy. It gives him a portable desktop to carry around with his favorite applications and the ability, should he choose to do so, This basically means, you burn it to a CD, set a computer to boot from the CD, start it up and you have a running Linux system in memory -- it saves nothing to disk unless specifically told to in a cumbersome manner-- and you can type in, compile and run C and C++ programs using one of the most sophisticated compilers out there, without having to go to the trouble of installing it. More information is at:
http://www.knoppix.net/wiki/Main_Page
You can do the same thing with Damn Small Linux which has among other advantages the iso file is much smaller and if you can get your machine to boot from a pen drive you can load it onto a very affordable one. More information is at:
http://damnsmalllinux.org/
I could fix the program above. Bluntly, I would prefer gets() or cin.getline for input but the first step is making sure you can compile one of these programs. If you can't get a new compiler. And hey, GCC has been around for twenty years now.
Reply:Look at the string class and cin.
Reply:i can help you with it, my msn is amwpessy@hotmail.com,or you can give me a email ------fadewolf@qq.com
Reply:/*I suggest to use Borland c++ compiler or turbo c++ compiler*/
/*Answer of your question is by using string method*/
/*see the following code*/
#include%26lt;stdio.h%26gt;
#include%26lt;conio.h%26gt;
#include%26lt;string.h%26gt;
void main()
{
char name[100];
printf("Enter your name ");
gets(name);
/*Then write any process you want*/
getch();
}
hyacinth
C++ beginner...?
Get a better compiler. I just had fun with this program. I compiled it on Linux using gcc and I'll show you the output in a minute.
#include %26lt;iostream%26gt;
#include %26lt;cstdio%26gt;
using namespace std;
int main(){
char Name[30];
char OtherName[30];
cout %26lt;%26lt; "Enter your name:";
cin %26gt;%26gt; Name;
cout %26lt;%26lt; "You entered " %26lt;%26lt; Name %26lt;%26lt; endl;
cout %26lt;%26lt; "Enter your name:";
gets(OtherName);
cout %26lt;%26lt; "You entered " %26lt;%26lt; OtherName %26lt;%26lt; endl;
return 0;
}
Here is what compiling and running it looks like:
jplatt@darkstar:~/Feb17$ g++ -o Name Name.cc
/tmp/cczWw2n0.o: In function `main':
Name.cc:(.text+0x204): warning: the `gets' function is dangerous and should not be used.
jplatt@darkstar:~/Feb17$ ./Name
Enter your name:John D. L. Platt
You entered John
Enter your name:You entered D. L. Platt
jplatt@darkstar:~/Feb17$
In other words, when I used cin %26gt;%26gt; Name it took everything I entered up to the first space and put it in name. There was more but it took it ALL and put in into OtherName. Happens. Your compiler should be able to do that if it's c++, not C.
Mind, GCC is not Linux-specific. In fact, my first experience with it was in 1987 when I was a word processor doing work for various engineering firms around RI which ran Unix. Linux came along in 1991. It's been ported to just about every OS which has come along since then. If you are on Windows the cheapest and least resource hungry is available for free download from http://www.delorie.com/djgpp/zip-picker....
There is an alternative: this is where one version of Linux shines. I'm talking about the livecd. You can download an iso file for free and burn it to a CD with nero or some other software. Knoppix was created by a computer consultant in Germany for use with his consultancy. It gives him a portable desktop to carry around with his favorite applications and the ability, should he choose to do so, This basically means, you burn it to a CD, set a computer to boot from the CD, start it up and you have a running Linux system in memory -- it saves nothing to disk unless specifically told to in a cumbersome manner-- and you can type in, compile and run C and C++ programs using one of the most sophisticated compilers out there, without having to go to the trouble of installing it. More information is at:
http://www.knoppix.net/wiki/Main_Page
You can do the same thing with Damn Small Linux which has among other advantages the iso file is much smaller and if you can get your machine to boot from a pen drive you can load it onto a very affordable one. More information is at:
http://damnsmalllinux.org/
I could fix the program above. Bluntly, I would prefer gets() or cin.getline for input but the first step is making sure you can compile one of these programs. If you can't get a new compiler. And hey, GCC has been around for twenty years now.
Reply:Look at the string class and cin.
Reply:i can help you with it, my msn is amwpessy@hotmail.com,or you can give me a email ------fadewolf@qq.com
Reply:/*I suggest to use Borland c++ compiler or turbo c++ compiler*/
/*Answer of your question is by using string method*/
/*see the following code*/
#include%26lt;stdio.h%26gt;
#include%26lt;conio.h%26gt;
#include%26lt;string.h%26gt;
void main()
{
char name[100];
printf("Enter your name ");
gets(name);
/*Then write any process you want*/
getch();
}
hyacinth
C++ Help Please!?
Where can I download a C++ compiler for free?
C++ Help Please!?
You can use Microsoft Visual Studio Express for free, though it has some limited features. If you're not doing anything complex, then this is a great tool.
http://www.microsoft.com/express/downloa...
Reply:www.bloodshed.net/devcpp.html
Reply:I agree with BalRog. You can get it from www.cygwin.com, but make sure you get the compiler and the debugger (gdb). You can also get several editors there, but I prefer Eclipse from www.eclipse.org (you need the CDT too)
Reply:Cygwin contains a free C++ compiler (g++) and a complete emulation of UNIX/Linux as well!
Reply:www.bloodshed.net/devcpp.html
C++ Help Please!?
You can use Microsoft Visual Studio Express for free, though it has some limited features. If you're not doing anything complex, then this is a great tool.
http://www.microsoft.com/express/downloa...
Reply:www.bloodshed.net/devcpp.html
Reply:I agree with BalRog. You can get it from www.cygwin.com, but make sure you get the compiler and the debugger (gdb). You can also get several editors there, but I prefer Eclipse from www.eclipse.org (you need the CDT too)
Reply:Cygwin contains a free C++ compiler (g++) and a complete emulation of UNIX/Linux as well!
Reply:www.bloodshed.net/devcpp.html
I want to download turbo c++or borland c++ to do programs. can u help me?
i tried and download borland c++ compiler 5.5
i even saw the website for its detailed instructions
but i am able to work with the compiler
plz help me
I want to download turbo c++or borland c++ to do programs. can u help me?
Turbo C++ is, as far as I am aware, a dos based program, which will not work properly if you are using windows.
If you still want it, here are the links:
http://dn.codegear.com/article/20841 (turbo c++ 2.01)
http://dn.codegear.com/article/21751 (turbo c++ 1.01)
Borland C++ 5.5 would work on windows, but as you noted is very difficult to use.
If you are trying to learn c++ programming I would suggest one of the following tools:
Dev CPP:
http://www.bloodshed.net/dev/devcpp.html (The first link under downloads)
Eclipse:
http://max.berger.name/howto/cdt/
Microsoft Visual C++ 2005 Express:
http://msdn.microsoft.com/vstudio/expres...
These are all great tools to learn, but unfortunately none of them have easy support for graphical applications.
If you are looking to develop windows GUI programs (graphical user interface), such as most applications which are in use today, you can do that by using one of the free libriaries for c++ graphics:
wxWidgets, ATL, qt...
But that is an advanced topic in c++, also not very easy to write such applications.
If you are looking for a quick tool to get started with windows applications then you might wish to consider switching on to C# (which is kinda new, but becoming very popular) by Microsoft. It is based on .NET and there is a download on the visual studio express link that I posted above. With this it is much easier to create regular windows applications, also the language is very similar to c++.
Hope that helps.
i even saw the website for its detailed instructions
but i am able to work with the compiler
plz help me
I want to download turbo c++or borland c++ to do programs. can u help me?
Turbo C++ is, as far as I am aware, a dos based program, which will not work properly if you are using windows.
If you still want it, here are the links:
http://dn.codegear.com/article/20841 (turbo c++ 2.01)
http://dn.codegear.com/article/21751 (turbo c++ 1.01)
Borland C++ 5.5 would work on windows, but as you noted is very difficult to use.
If you are trying to learn c++ programming I would suggest one of the following tools:
Dev CPP:
http://www.bloodshed.net/dev/devcpp.html (The first link under downloads)
Eclipse:
http://max.berger.name/howto/cdt/
Microsoft Visual C++ 2005 Express:
http://msdn.microsoft.com/vstudio/expres...
These are all great tools to learn, but unfortunately none of them have easy support for graphical applications.
If you are looking to develop windows GUI programs (graphical user interface), such as most applications which are in use today, you can do that by using one of the free libriaries for c++ graphics:
wxWidgets, ATL, qt...
But that is an advanced topic in c++, also not very easy to write such applications.
If you are looking for a quick tool to get started with windows applications then you might wish to consider switching on to C# (which is kinda new, but becoming very popular) by Microsoft. It is based on .NET and there is a download on the visual studio express link that I posted above. With this it is much easier to create regular windows applications, also the language is very similar to c++.
Hope that helps.
Need a clarification about #pragma directive in C++?
When I compiled and ran the below code in Turbo-C++ compiler it is running fine. But when I tried to run the same code in VC++6.0 compiler it is giving two warnings as "Unknown Pragma"... it is not recognizing the key words Startup and exit. That is why the warnings a coming. Can you pls mention the equivalent CPP code which can run on a VC++6.0 compiler.
The code is as below:
#include%26lt;iostream.h%26gt;
#include%26lt;conio.h%26gt;
void f1();
void f2();
#pragma startup f1
#pragma exit f2
main()
{
cout%26lt;%26lt;"EXECUTING MAIN \ n \ n";
return(0);
}
void f1()
{
cout%26lt;%26lt;"EXECUTING F1 \ n \ n";
}
void f2()
{
cout%26lt;%26lt;"EXECUTING F2 \ n \ n";
}
OUTPUT:
EXECUTING F1
EXECUTING MAIN
EXECUTING F2
Need a clarification about #pragma directive in C++?
Ok, this is what happens in Turbo C++. The statement #pragma startup f1 tells the preprocessor that in this program the special module name startup, usually predefined as pointing to the library startup routine; is to have the function name f1 expanded into it at the end of the function. So, when the program is loaded and about to begin execution, before it begins main; it finds and executes f1. The same happens with the f2 function and exit.
What you need to know to make this work is what pragma name the VC++ 6.0 compiler uses instead of startup. There are three ways to find out. From worst to best: 1) Guess and try, it could take thirty seconds or thirty years. 2) Search out an answer from the included header files. Probably get done in a few days at most. 3) Quickest and best is ask Microsoft by using the search facilities at the link below. I hope this helps you out.
The code is as below:
#include%26lt;iostream.h%26gt;
#include%26lt;conio.h%26gt;
void f1();
void f2();
#pragma startup f1
#pragma exit f2
main()
{
cout%26lt;%26lt;"EXECUTING MAIN \ n \ n";
return(0);
}
void f1()
{
cout%26lt;%26lt;"EXECUTING F1 \ n \ n";
}
void f2()
{
cout%26lt;%26lt;"EXECUTING F2 \ n \ n";
}
OUTPUT:
EXECUTING F1
EXECUTING MAIN
EXECUTING F2
Need a clarification about #pragma directive in C++?
Ok, this is what happens in Turbo C++. The statement #pragma startup f1 tells the preprocessor that in this program the special module name startup, usually predefined as pointing to the library startup routine; is to have the function name f1 expanded into it at the end of the function. So, when the program is loaded and about to begin execution, before it begins main; it finds and executes f1. The same happens with the f2 function and exit.
What you need to know to make this work is what pragma name the VC++ 6.0 compiler uses instead of startup. There are three ways to find out. From worst to best: 1) Guess and try, it could take thirty seconds or thirty years. 2) Search out an answer from the included header files. Probably get done in a few days at most. 3) Quickest and best is ask Microsoft by using the search facilities at the link below. I hope this helps you out.
Trouble in the header file pshpack.h in C during compilation.?
While compiling a C program to connect the front end C, with the MS-Access database, I get a FATAL error like this::
"" Fatal INCLUDE\PSHPACK.H 7 : Error Directive " 1 as alignment isn't supported by the compiler""
What is a fatal error?How do I rectify this error. I have a TURBO C/C++ compiler and I downloaded this include file %26lt;pshpack.h%26gt; only recently.
Trouble in the header file pshpack.h in C during compilation.?
A fatal error is any error that the compiler / linker /assembler has designated, internally or by an input switch, to stop creation of output files on. In other words, it is "fatal" to the process. These are usually big boo-boos.
In this case, I have little information to base an answer on. It would have been nice to know what version of the compiler, where the file was downloaded from and what it is touted to do and by who.
At a guess from what I see (including the error verbatim was very smart!), the code alignment is wrong and set at 1. Probably this relates to boundary alignments, which enter into the complex world of Windows file format options, such as PE(Packed Executable) files. I would hazard a guess that one of the following two things is happening.
1). Your version of Borland Turbo C / C++ is too old to have facilities to handle this type of boundary alignment as the library and header files need.
2). Your compiler is capable to handle this type of file alignment, but the automatic or default settings ( which are usually set to allow most compilations to be as painless as possible!) have been accidentally or intentionally changed to something non-compatible with the current project.
I hope that this gives some idea of the problems roots. When in doubt, investigate the documentation thoroughly. All advice is free and damn well worth it!
poppy
"" Fatal INCLUDE\PSHPACK.H 7 : Error Directive " 1 as alignment isn't supported by the compiler""
What is a fatal error?How do I rectify this error. I have a TURBO C/C++ compiler and I downloaded this include file %26lt;pshpack.h%26gt; only recently.
Trouble in the header file pshpack.h in C during compilation.?
A fatal error is any error that the compiler / linker /assembler has designated, internally or by an input switch, to stop creation of output files on. In other words, it is "fatal" to the process. These are usually big boo-boos.
In this case, I have little information to base an answer on. It would have been nice to know what version of the compiler, where the file was downloaded from and what it is touted to do and by who.
At a guess from what I see (including the error verbatim was very smart!), the code alignment is wrong and set at 1. Probably this relates to boundary alignments, which enter into the complex world of Windows file format options, such as PE(Packed Executable) files. I would hazard a guess that one of the following two things is happening.
1). Your version of Borland Turbo C / C++ is too old to have facilities to handle this type of boundary alignment as the library and header files need.
2). Your compiler is capable to handle this type of file alignment, but the automatic or default settings ( which are usually set to allow most compilations to be as painless as possible!) have been accidentally or intentionally changed to something non-compatible with the current project.
I hope that this gives some idea of the problems roots. When in doubt, investigate the documentation thoroughly. All advice is free and damn well worth it!
poppy
Are there any c++ compilers that work with vista?
for free?i try using dev-c++ but it doesnt compile.....
and it should. im using windows vista premium.
when i was using xp it worked.
Are there any c++ compilers that work with vista?
You can allways use the .NET SDK which includes Microsoft's C++ compiler, amongst many other. It is included with the Express Edition for Visual C++ 2005 which can be downloaded for free.
ANother solution would be Mingw compiler with code::blocks. Code::Blocks is an IDE which virtually runs with any C/C++ compiler you tell it to run.. By default it comes configured with Mingw.
http://www.codeblocks.org/
Reply:Microsoft makes Express 2005 available as a free download.
http://msdn.microsoft.com/vstudio/expres...
and it should. im using windows vista premium.
when i was using xp it worked.
Are there any c++ compilers that work with vista?
You can allways use the .NET SDK which includes Microsoft's C++ compiler, amongst many other. It is included with the Express Edition for Visual C++ 2005 which can be downloaded for free.
ANother solution would be Mingw compiler with code::blocks. Code::Blocks is an IDE which virtually runs with any C/C++ compiler you tell it to run.. By default it comes configured with Mingw.
http://www.codeblocks.org/
Reply:Microsoft makes Express 2005 available as a free download.
http://msdn.microsoft.com/vstudio/expres...
I'm using the netbeans IDE with the C++ Dev Pack i'm using cygwin as the compiler?
So what is your question?
Subscribe to:
Posts (Atom)