0

When I use check50 command to check my vigenere code , It gives me that line with green color:

handles argc > 2 

and that with red color :

:)handles lack for argv[1]
\expected output not standard error of .......

this is the screenshot of the error

https://www.dropbox.com/s/byvjxc2nfqwegpo/error.PNG?dl=0

and this is my source code :

#include<stdio.h>
#include<cs50.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>

// the use will input his keyword .
// get n = the strlen(argv[1])   (n is string lenght of keyword )

int main (int argc , string argv[] )
{
    int len_argv = strlen( argv[1] ) ;   

    // make sure the argc = 2
    if ( argc != 2  )
    {

...snip code

5
  • try replacing printf("input one keyword alphabetic [12]\n") with printf("\n")
    – sinister
    Aug 31 '14 at 16:41
  • it doesn't work unfortunately sinister Aug 31 '14 at 18:05
  • 1
    Can you update your question with a link to the actual sandbox check50 results? That will make it easier to diagnose.
    – curiouskiwi
    Aug 31 '14 at 22:30
  • please don't post your entire code. that breaks the honor code. What about your check50 results?
    – curiouskiwi
    Sep 1 '14 at 9:39
  • the check50 results is on the link Sep 1 '14 at 9:42
2

So you've got this:

int len_argv = strlen( argv[1] ) ;   <--------

// make sure the argc = 2
if ( argc != 2  )
{

What happens if argv[1] doesn't exist? You will segfault. You need to check if it exists before you actually try to do anything with it. You are checking afterwards.

1
  • yes, that was my problem, thanks curiouskiwi Sep 1 '14 at 9:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .