First of all, I'd like to introduce myself to the C-Programming.com boards. I'm taking CS in college and not going to class for the summer made me rusty. If anyone can provide me with some insight with why I get errors when building this program, it would be helpful.
Code:
#include <cstring>
#include <iostream>
#include <cmath>
using namespace std;
void encode(char[] ,char[] ,char[] );
void main()
{
char table[5][10];
char statement[50];
char keyword[10];
cout<<"Please enter your statement,max 50 characters, all lowercase, with no spaces."<<endl;
cin.get(statement,50);
cout<<"Please enter your keyword. Do not repeat any letters.";
cin>>keyword;
cout<<"Our original statement is "<<statement<<endl;
encode(statement,keyword,table);
for (int y=0;y<strlen(keyword);y++)
{
for (int x=0;x<ceil(strlen(statement)/strlen(keyword))+1;x++)
{
cout<<table[x][y];
}
cout<<' ';
}
cout<<endl<<endl;
}
void encode(char statement[], char keyword[], char table[])
{
int i=0;
int keylength = strlen(keyword);
int messagelength = strlen(statement);
for(int x=0;x<ceil(messagelength/keylength)+1;x++)
for(int y=0;y<keylength;y++)
{
table[x][y] = statement[i];
i++;
}
}
Thanks in advance. ^_^