Computer Science help
•
7 Dec 2011, 00:08
•
Journals
Hi guys!
I have a test on computer science tomorrow. It's basically the basics of C++, so if any of you guys are willing to help me, send me a message!
I have a test on computer science tomorrow. It's basically the basics of C++, so if any of you guys are willing to help me, send me a message!
How to bubble sort?
How to use arrays. Type my name backwards, etc..
What is in cin.get and cin.ignore
fp=fopen("lammas.txt","r");
if(!fp)return 1;
// and well u can find rest out in inet
http://mathbits.com/mathbits/compsci/arrays/bubble.htm
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
string e = "lammas";
cout << e << endl;
for(int i = (e.length() - 1); i != -1 ; i-- ) {
cout << e;
}
return 0;
}
for int u need to be more creative
gets console input(http://www.cplusplus.com/forum/general/465/), and ignore ignores '\n' - endline(http://www.cplusplus.com/forum/beginner/9148/)
I need you to explain to me what is going on -_-
fp=fopen("lammas.txt","r");
if(!fp)return 1;
That is C not C++.
http://www.cplusplus.com/reference/iostream/fstream/
The code you posted is wrong aswell. You should be using string::size_type instead of int for indexing strings. While it does not really matter later it might cause problems plus it's just bad coding.
stream.get gets the next char from a stream.
Ignore:
http://www.cplusplus.com/reference/iostream/istream/ignore/
stream.ignore(x, c);
Ignores the next x chars from a stream or until a char c is found.
ohh yes, the koma thing ':/
might be but i wanted name spelling and easy array way aswell. and i dont think that he will counter index over int on the test.