We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,672 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Encrypt a siimple string

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;}
2
Contributors
1
Reply
2 Days
Discussion Span
1 Year Ago
Last Updated
2
Views
mattiapdo
Newbie Poster
5 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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.

LdaXy
Light Poster
32 posts since Dec 2011
Reputation Points: 10
Solved Threads: 2
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0574 seconds using 2.7MB