- This topic is empty.
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.
IT, Programming, & Web Development › Forums › CS50’s Introduction to Computer Science by Harvard University on Edx › Week 2: [Arrays] – Functions, Variable and Scope, Debugging, Arrays, and Command Line Arguments › How to store entered 26 character values against argv[1] to string type array key
#include
#include
#include
#include
#include
int main(int argc, string argv[])
{
int counter = 0;
if (argc != 2)
{
return 1;
}
else
{
printf("enter plainkey: ");
}
string key = argv[1][];
int t = strlen(key);
if(t != 26)
{
return 1;
}
while(counter < t)
{
isdigit (argv[1][counter]);
return 1;
counter = counter + 1;
}
string s = get_string("plaintext: ");
int countstring = strlen(s);
for(int i = 0; i <= countstring; i++)
if (isalpha s)
{
int s= int t;
t = s;
}
else
{
s = s;
}
printf("ciphertext: %s",s);
}
On compiling,
There is a problem with:
string key = argv[1][ ];
How do I denote 26 characters that are supposed to be entered by the user against argv[1]. Need to store entered 26 character values to key.
Reply
You should note that agrv[1]
is a string while argv[1][ ]
is a character. You are declaring key as string. So you should be assigning a value of string to it and not character. Use string key = argv[1];
[learn_press_profile]