I'm getting a compile error with this bit:

int valid(const char str[]){
	int i, total = 0, multiplier = 10;

	for(i=0; i < 11; i++){
		str[i] * multiplier += total; //this line is an invalid lvalue
		multiplier--;
	}
	
	if(total % 11 != 0)
		return 0;
	else
		return 1;

I send a string of numbers to this function, then I want to multiply each value in the string and add the product to a running total.

str * multiplier += total;

You are multiplying on the left side of the assignment operator +=.
Note that an assignment operator is not the same thing as an equal sign in math.
This is allowed in a computerlanguage : x = x +1;
You cannot do that in math.
This is allowed in math: a * b = t
You cannot do that in a computer language .

Also, I never see you call any kind of function to convert the string to an int:

#include <iostream>
#include <sstream>

using namespace std;

int main(int argc, char **argv)
{
	stringstream ss;
	std::string x;
	int integer;

	x = "5";
	ss << x;
	ss >> integer;

	cout << integer << endl;

	return 0;
}

or you could do (though, it's not recommended for some reason):

#include <iostream>
#include <sstream>

using namespace std;

int main(int argc, char **argv)
{
	std::string x;
	int integer;

	x = "5";
	
	integer = atoi(x.c_str());

	cout << integer << endl;

	return 0;
}

Got it, thanks for the help

int valid(const char str[]){
	int i, x,  multiplier = 10, total = 0;
	for(i=0; i < 10; i++){
		x = (str[i]-48);
		x *= multiplier;
		total += x;
		multiplier--;  
	}
	if(total % 11 != 0)
		return 0;
	else
		return 1;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.