All pastes #803172 Raw Edit

streambuffer

public text v1 · immutable
#803172 ·published 2007-11-30 23:19 UTC
rendered paste body
/*
Corby Campbell
Cs1600-001
final
*/

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

string charToMorse(char);
string morseToChar(string);

// function main begins program execution
int main()
{
	streambuf message; //C:\Documents and Settings\hp\My Documents\cs 1600\homework (inbox)\Final\Final.cpp:
Error E2247 C:\Documents and Settings\hp\My Documents\cs 1600\homework (inbox)\Final\Final.cpp 18: 'streambuf::basic_streambuf()' is not accessible in function main()


	cout<<"Input Morse Code Message: ";
	//cin>>message;
	//cin.getline((streambuf)message,'\n');
	cin.getline(message,'\n');
	for (int i = 0; i < message.size(); i++){
		//cout<<"char "<<i<<" = "<<toupper(message[i])<<"  "<<stringToMorse(toupper(message[i]))<<endl;
		cout<<charToMorse(toupper(message[i]))<<" ";
	}
	cout<<endl;

	return 0; // indicate successful termination
} // end main

string morseToChar(string s){
	string returnString;

	return returnString;
}

string charToMorse(char c){
	string returnString;
	if (c == 65)
		returnString = ".-";
	else if (c == 66)
		returnString = "-...";
	else if (c == 67)
		returnString = "-.-.";
	else if (c == 68)
		returnString = "--..";
	else if (c == 69)
		returnString = ".";
	else if (c == 70)
		returnString = "..-.";
	else if (c == 71)
		returnString = "--.";
	else if (c == 72)
		returnString = "....";
	else if (c == 73)
		returnString = "..";
	else if (c == 74)
		returnString = ".---";
	else if (c == 75)
		returnString = "-.-";
	else if (c == 76)
		returnString = ".-..";
	else if (c == 77)
		returnString = "--";
	else if (c == 78)
		returnString = "-.";
	else if (c == 79)
		returnString = "---";
	else if (c == 80)
		returnString = ".--.";
	else if (c == 81)
		returnString = "--.-";
	else if (c == 82)
		returnString = ".-.";
	else if (c == 83)
		returnString = "...";
	else if (c == 84)
		returnString = "-";
	else if (c == 85)
		returnString = "..--";
	else if (c == 86)
		returnString = "...-";
	else if (c == 87)
		returnString = ".--";
	else if (c == 88)
		returnString = "-..-";
	else if (c == 89)
		returnString = "-.--";
	else if (c == 90)
		returnString = "--..";
	else if (c == 48)
		returnString = "-----";
	else if (c == 49)
		returnString = ".----";
	else if (c == 50)
		returnString = "..---";
	else if (c == 51)
		returnString = "...--";
	else if (c == 52)
		returnString = "....-";
	else if (c == 53)
		returnString = ".....";
	else if (c == 54)
		returnString = "-....";
	else if (c == 55)
		returnString = "--...";
	else if (c == 56)
		returnString = "---..";
	else if (c == 57)
		returnString = "----.";
	return returnString;
}

/*i know what its beef with these is...
Error E2285 C:\Documents and Settings\hp\My Documents\cs 1600\homework (inbox)\Final\Final.cpp 23: Could not find a match for 'istream::getline(streambuf,char)' in function main()
Error E2316 C:\Documents and Settings\hp\My Documents\cs 1600\homework (inbox)\Final\Final.cpp 24: 'size' is not a member of 'streambuf' in function main()
Error E2094 C:\Documents and Settings\hp\My Documents\cs 1600\homework (inbox)\Final\Final.cpp 26: 'operator+' not implemented in type 'streambuf' for arguments of type 'int' in function main()
Warning W8057 C:\Documents and Settings\hp\My Documents\cs 1600\homework (inbox)\Final\Final.cpp 37: Parameter 's' is never used in function morseToChar(string)
*** 4 errors in Compile ***
*/