<< errors

My code is:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <iostream.h>
#include <ctype.h>
#include <vector>
#include <conio.h>

#include <string.h>

using std::vector;
using std::string;

std::vector<char *> nocode;
std::vector<char *> code;
std::string input("");

char inputs[500];
char y_n;
int x;

void encode();

int main()
{
	do{
		cout << "Input the line:" << endl;
		cin.ignore(80, '\n');
		cin.getline(inputs, 60);
		cin.ignore(80, '\n');
		input=inputs;
		

		cout << endl;
		cout << input << '\n';

		system("CLS");

		cout << "Unencrypted:\n";
		cout << input;

		encode();

		cout << "Encrypted:\n";
		cout << input;

		input="";
		cout << "Do another line? (y/n)";
		cin >> y_n;
	}while(tolower(y_n)!='n');
	return 0;
}


void encode()
{
	for(int x=0; x<int(input.size); x++)
	{
		if(toupper(input[x])=='A'||toupper(input[x])=='E'||toupper(input[x])=='I'||toupper(input[x])=='O'||toupper(input[x])=='U')
		{
			input[x]=input[x]-3;
			if(input[x]<65)
			{
				input[x]=90-(65-input[x]); //make sure it's a letter
			}
			else if(input[x]<97&&input[x]>90)
			{
				input[x]=122-(97-input[x]); //make sure it's a letter
			}
		}
		else
		{
			input[x]=input[x]+5;
			if(input[x]>122)
			{
				input[x]=97+(input[x]-122); //make sure it's a letter
			}
			else if(input[x]>90&&input[x]<97)
			{
				input[x]=65+(input[x]-97); //make sure it's a letter
			}
		}
	}
}


My errors are
"error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conve"

I have three of them, every time I try to output the string input. I can't use getline to receive "input," just as an addendum. Anybody know why I'm getting these errors? it's been almost an hour now and I still can't figure it out.

EDIT: it's lines 32, 37, and 42
Last edited on
I wonder if this has to do with using std::string mixed with iostream.h's cout...

The preferred headers are #include <iostream> , etc. (without the .h). Then to bring each unknown symbol into scope you can use using std::symbol; or using namespace std; to bring them all in.
To add, you would need at least:
1
2
3
using std::cin;
using std::cout;
using std::endl;


I've also been a little confuse with std::string, I don't think this is the same type of string one gets when he/she includes <string>, but I could be wrong. I don't really understand why you extract a char array and then convert it to a string, but that is another story.
Last edited on
Whoa whoa whoa whoa whoa ...

I've seen so many people use #include <iostream.h> , when iostream.h is obselete. Use iostream (no extension) instead. Same with #include <string.h> and #include <string> , don't use the extension.
Last edited on
MSVC++ 6.0 Enterprise does not have iostream. This comes up every time. it uses non-standard headers. Today I gave up and switched to code::Blocks. Will keep you updated.
x<input.size

I'm being told that's illegal... x is of int type, and input is a string. Any ideas? I've tried typecasting (in fact I think it's typecasted above) but that didn't help.

Exact error:
error: invalid use of member (did you forget the '&'?)


do i need an &?
x < input.size()
'Preciate it.
Is there any std::string equivalent for the cstring spanexcluding() function? I used the same thread because it's for the same program.
What does it do?
Hello everyone

I am not a programmer.
I was running a data analysis software for ecology and there was the following debug error:
heap corruption detected: before normal block (#271) at 0x026A8C68
Do you think I can ignore the error? what I have to resolve this?
The problem does not occurs with all .txt files with data which I import to the software. Only for some .txt.
Thank you very much
Regards
Jose
closed account (zb0S216C)
macedo wrote:
"Do you think I can ignore the error?"

No. Heap errors need addressing as soon as they arise. I recommend reporting the error to the developers so that they can home-in on the issue. Be sure to provide a detailed report.

macedo wrote:
"The problem does not occurs with all .txt files with data which I import to the software. Only for some .txt."

Are the troublesome text files of a large capacity (2:4GB+)?

Wazzak
Thanks for the help
Who are the developers (C++ or from the software)?
The text files are of very small size

regards
Jose
closed account (zb0S216C)
Send it to the developers of the software. As for your files, perhaps there data inside the file has the wrong format? Without a sample of the file, it's difficult to determine.

I don't want us to hijack this thread, so create a new discussion and we'll go from there.

Wazzak
Err... bump? lol

@moorecm it returns a substring that cuts out all of a character, for example

Cstring str("Hello Test");
Cstring stri;


stri=str.spanexcluding(" ");

stri would then be equal to "HelloTest".

EDIT: for any who just joined this thread, the question is are there any std::string equivalents for the cstring spanexcluding() function
Last edited on
http://cplusplus.com/reference/algorithm/remove/
http://cplusplus.com/reference/string/string/erase/

Something like this:
1
2
3
string str( "Hello Test" );
str.erase( remove( str.begin(), str.end(), ' ' ), str.end() );
cout << str << endl;
Would that work for more than one space?
i.e. "Hello This Is A Test"
Test it!
you rock.
Topic archived. No new replies allowed.