Hi!
Could aneone take a look at this code?
I'm pretty n00b to C++ and i want to return an array from a function within af class!
But it gives me an error saying: "initializer fails to determine size of `ord'" and "invalid initializer".
I am btw compiling with Dev-C++ 4.9.9.2
Here's the code:
Code:
#include <iostream>
using namespace std;
class krypter
{
private:
string a;
int size;
public:
int tal_til_bogstav_ascii (char a[], int size)
{
for(int i=0;i<=size;i++)
{
switch (a[i])
{
// Dont mind this function!
}
}
}
int calculate_array (char a[])
{
size = 0;
for(int i=0;i<=100;i++)
{
if(a[i] != 0)
{
size = size + 1;
}
else
break;
}
return (size);
}
char set_array (char *a[], const int size)// this is the one!
{
char array[size];
for(int i=0;i<=100;i++)
{
if(a[i] != 0)
{
array[i] = *a[i];
}
else
break;
}
return (*array);
}
};
int main()
{
start:
krypter size1;
krypter array;
char input[100];
cout << "What's ur word?" << endl;
cin >> input;
char * inp = input;
int size = size1.calculate_array(input);
cout << "There's " << size << " letters/signs in ur word" << endl<< endl;
const int stor = size;
char** in = (char**) input;
char ord[] = array.set_array(in, size);// SHOULD init. ord[] but no :S
for(int i=0;i<size;i++)
cout << ord[i];
goto start;
return 0;
}