It is currently Thu May 28, 2015 9:55 am


C++

C++

Postby tip32926 » Thu Feb 08, 2007 9:13 pm

cout << "Input file: ";
fstream in(cin.getline(filename,80));


im trying to use what the user enters as the input and output

thanks for your help
<a href="http://www.nerdtests.com/ft_cg.php?im">
<img src="http://www.nerdtests.com/images/ft/cg.php?val=0848" alt="My computer geek score is greater than 100% of all people in the world! How do you compare? Click here to find out!"> </a>
User avatar
tip32926
baby nerd
 
Posts: 36
Joined: Tue Apr 04, 2006 8:11 am
Location: florida

Postby ColdShadow » Thu Mar 01, 2007 12:52 am

Code: Select all
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
{
   
    string var;
    cout << "Enter in a number:";
    cin >> var;
    cout << var;

    system("PAUSE");
    return 0;
}

We can get input as a variable by using cin.
ColdShadow
total nOOb
 
Posts: 3
Joined: Thu Mar 01, 2007 12:39 am

Postby cheryl » Thu Mar 01, 2007 7:20 am

ColdShadow wrote:
Code: Select all
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
{
   
    string var;
    cout << "Enter in a number:";
    cin >> var;
    cout << var;

    system("PAUSE");
    return 0;
}

We can get input as a variable by using cin.


I know next to nothing about C++.

Can you tell me the purpose of the iostream include? I've noticed that it must be present for even the simplest program.

And by the way, welcome to our forum : )
fangirl of nerds

Corn chips are no place for a mighty warrior.
User avatar
cheryl
nerd god
 
Posts: 1349
Joined: Wed Jul 06, 2005 2:23 am
Location: Central Florida

Postby Astronut » Thu Mar 01, 2007 10:11 am

cheryl wrote:
ColdShadow wrote:
Code: Select all
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
{
   
    string var;
    cout << "Enter in a number:";
    cin >> var;
    cout << var;

    system("PAUSE");
    return 0;
}

We can get input as a variable by using cin.


I know next to nothing about C++.

Can you tell me the purpose of the iostream include? I've noticed that it must be present for even the simplest program.

And by the way, welcome to our forum : )


Woohoo! I know this one!

iostream calls a library that includes the cin, cout, and endl functions, as well as others. These are very common functions, and the only way to get them is to include iostream. There are other ways, but this seems to be the most often used.
Before I die, I will make infinity smaller.
<a href="http://www.nerdtests.com/ft_nq.php?im"><img src="http://www.nerdtests.com/images/ft/nq.php?val=5762" alt="I am nerdier than 87% of all people. Are you nerdier? Click here to find out!"></a>
User avatar
Astronut
young nerd
 
Posts: 92
Joined: Mon Feb 26, 2007 8:59 pm
Location: Earth, Sol System, Milky Way

Postby tip32926 » Thu Mar 01, 2007 4:02 pm

#include <iostream>
#include <fstream>
#include <string>
using namespace std;


int main()
{
char letter;
string word, namein, nameout;
vector<string> one;

cout << "Input file: ";
cin >> namein;
ifstream input(namein.c_str());

return 0;
}

this is what i used(sry i meant to post it
<a href="http://www.nerdtests.com/ft_cg.php?im">
<img src="http://www.nerdtests.com/images/ft/cg.php?val=0848" alt="My computer geek score is greater than 100% of all people in the world! How do you compare? Click here to find out!"> </a>
User avatar
tip32926
baby nerd
 
Posts: 36
Joined: Tue Apr 04, 2006 8:11 am
Location: florida

Postby ColdShadow » Thu Mar 01, 2007 5:52 pm

cheryl wrote: know next to nothing about C++.

Can you tell me the purpose of the iostream include? I've noticed that it must be present for even the simplest program.

I quote wikipedia:
iostream is a header file which is used for input/output in the C++ programming language. The name stands for Input/Output Stream. In C++ and its predecessor, the C programming language, there is no directly-included method for streaming data input or output. Instead, these are combined as a library. iostream handles basic input and output for C++, whereas stdio.h is used in C. iostream uses the objects cin, cout, and cerr for sending data to and from the standard streams input, output, and error respectively.

iostream is only needed if the program uses cin, cout, or cerr
ColdShadow
total nOOb
 
Posts: 3
Joined: Thu Mar 01, 2007 12:39 am

Postby cheryl » Fri Mar 02, 2007 7:48 am

ColdShadow wrote:
cheryl wrote: know next to nothing about C++.

Can you tell me the purpose of the iostream include? I've noticed that it must be present for even the simplest program.

I quote wikipedia:
iostream is a header file which is used for input/output in the C++ programming language. The name stands for Input/Output Stream. In C++ and its predecessor, the C programming language, there is no directly-included method for streaming data input or output. Instead, these are combined as a library. iostream handles basic input and output for C++, whereas stdio.h is used in C. iostream uses the objects cin, cout, and cerr for sending data to and from the standard streams input, output, and error respectively.

iostream is only needed if the program uses cin, cout, or cerr


Wow! So compared to a simple language like BASIC, which uses statements like "input x" or "print x" for input and output, C++ must be extremely customize-able. If I understand you correctly, there is no built in function for user input/output, you have to call up a pre-written subroutine to get that function? And iostream is one possible example of an input/output routine, yes?

Well, I can see why operating systems are written in this language...
fangirl of nerds

Corn chips are no place for a mighty warrior.
User avatar
cheryl
nerd god
 
Posts: 1349
Joined: Wed Jul 06, 2005 2:23 am
Location: Central Florida

Postby ColdShadow » Sun Mar 04, 2007 3:18 am

cheryl wrote:
ColdShadow wrote:
Wow! So compared to a simple language like BASIC, which uses statements like "input x" or "print x" for input and output, C++ must be extremely customize-able. If I understand you correctly, there is no built in function for user input/output, you have to call up a pre-written subroutine to get that function? And iostream is one possible example of an input/output routine, yes?

Well, I can see why operating systems are written in this language...

Iostream is a library of functions you can call.

Operating systems aren't programmed in c++ silly:)
ColdShadow
total nOOb
 
Posts: 3
Joined: Thu Mar 01, 2007 12:39 am

Postby Andre » Sun Mar 04, 2007 4:41 am

Operating Systems are usually written in C, not C++
User avatar
Andre
baby nerd
 
Posts: 47
Joined: Fri Jul 22, 2005 3:49 am
Location: Beek, Limburg, Netherlands

Postby cheryl » Sun Mar 04, 2007 8:02 am

ColdShadow wrote:
cheryl wrote:
ColdShadow wrote:
Wow! So compared to a simple language like BASIC, which uses statements like "input x" or "print x" for input and output, C++ must be extremely customize-able. If I understand you correctly, there is no built in function for user input/output, you have to call up a pre-written subroutine to get that function? And iostream is one possible example of an input/output routine, yes?

Well, I can see why operating systems are written in this language...

Iostream is a library of functions you can call.

Operating systems aren't programmed in c++ silly:)


Ah, I was told that Unix was written in C in 1969, and that C++ was a more modern, enhanced version of the old C language, so I thought... Also, it seems to me that everytime someone talks about making a custom kernal for their particular install of Linux, speak of compiling C++ source code. Now I'm really confused. As well as silly.
fangirl of nerds

Corn chips are no place for a mighty warrior.
User avatar
cheryl
nerd god
 
Posts: 1349
Joined: Wed Jul 06, 2005 2:23 am
Location: Central Florida

Postby EdTheN00bProgrammer » Sun Jun 10, 2007 6:21 am

http://www.cplusplus.com/reference/iostream/

It would seem that the iostream class is the parent of the istream and ostream classes.

i think that iostream stands for in/out stream, ostream stads for outstream, istream stands for instream, ifstream stands for in file stream and ofstream stands for out file stream.

C++ isn't as powerful? What makes you think that?

I'm a n00b to C++, so I'm not trying to say that C++ is as powerful; I'm just wondering.
Culture is boring - reject it.
Hobbies are interesting - indulge in them.
Be a nerd.
EdTheN00bProgrammer
wise nerd
 
Posts: 485
Joined: Thu May 10, 2007 7:04 am

Postby kingofnerds » Mon Jun 25, 2007 8:28 am

C++ is a higher level language, it is object oriented, whereas C is not. C relies upon loops and sequential order, C++ can be event driven. Sure you can do Event driven things with C, but it is much easier to do it with C++. Also programs written in C generally tend to run faster and take less drive space than those written in C++.
in the end Nerds with Linux will Rule the world
BullFrogHost.net = Top Quality Hosting at an affordable Price
User avatar
kingofnerds
mature nerd
 
Posts: 183
Joined: Sat Dec 10, 2005 3:02 pm
Location: Utah, USA

Postby EdTheN00bProgrammer » Thu Jun 28, 2007 2:31 pm

To what extent?
Culture is boring - reject it.
Hobbies are interesting - indulge in them.
Be a nerd.
EdTheN00bProgrammer
wise nerd
 
Posts: 485
Joined: Thu May 10, 2007 7:04 am


Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests

cron