1.11M Members

Encrypt a siimple string

 
0
 

It doesn't run! Can you help me please?
Devc++ compiles it, and also launch the exe file, but it stops after the second for cycle! Why? :D

#include <iostream>
#include <string>
using namespace std;

int main()
{
    int N,i,z;
    cout<<"Digitare il umero di caratteri che contengono il nome ";
    cin>>N;
    string cod[N],nome[N];
    int ch[N];
    cout<<"Nome in codice "<<endl;
    for(i=0;i<N;i++)
    cin>>cod[i];
    cout<<"Chiave di lettura "<<endl;
    for(i=0;i<N;i++)
    cin>>ch[i];
    
    for (i=0;i<N;i++)
     nome[i+1]=cod[ch[i+1]];
    
    cout<<endl;
    for (i=0;i<N;i++)
    cout<<nome[i]<<endl;
    system ("Pause");
    return 0;}
 
0
 

well, i can tell you some problems with it.

your string variables make a reeference to an array but it has a value of zero.

int i;
std::string string1[i]; //error: i is not initiliazed, and assumed to be zero
int j = 1;
std::string string2[j]; //no error. arrays must have a value of 1 or greater

you variable nome, is referenced but does not have a definition anywhere. ambiguous
variables are not supported.

ch cannot determine it's value. in order to alleviate this you have to get the value of n, before ch is define or initialize it as one and replace it later in the code.

if you fix those errors it should work.

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: