What kind of statment or basic structure should i use here?

#include <iostream>
#include <cstdio>

using namespace std;

int main (int nNumberofArgs, char* pszArgs)
{
int a=1;
int b=2;
int c=3;
int d=4;
int e=5;
int f=6;
int g=7;
int h=8;
int i=9;
int j=10;
int k=11;
int l=12;
int m=13;
int n=14;
int o=15;
int p=16;
int q=17;
int r=18;
int s=19;
int t=20;
int u=21;
int v=22;
int w=23;
int x=24;
int y=25;
int z=26;
int name;

cout<<"Write the text you want to be encrypted: ";
cin>> name;







return 0;
}






I dont know what i need to have in the gap. I wan the program to see the word that was typed in and take each letter and make it a number. I wouldn't use IF statments right??
http://www.cplusplus.com/reference/stl/map/ Try this data structure. A map is made of key/value pairs so in your case each letter would be a key and each corresponding number would be a value;

Also you want to take a character array as input not an int. Then iterate through the character array in a for loop and check each character with an if statement.

something like this
1
2
3
4
5
char* test = "test";
for( char* c = test; *c != NULL; c++ )
{

}
Last edited on
How would i make a character array? i am very new to programming and this is onyl my third program.
you should try googling this stuff first. To make a character array you could do something like this:

1
2
3
const char cCharArray[50] = "This is a char array that is read only";

char* pCharArray = "this is a pointer to an array of characters";


Things you should read:
http://www.cplusplus.com/doc/tutorial/

More specifically:
http://www.cplusplus.com/doc/tutorial/ntcs/
http://www.cplusplus.com/doc/tutorial/pointers/
Topic archived. No new replies allowed.