Questions tagged [command-line-arguments]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
8 views

Strange CL output

I was testing my code to see if the command line argument's characters are digits but after plugging a random argument that was a mix of letters and numbers, I obtained a strange output. See what you ...
0
votes
1answer
52 views

pset7 houses printing the error message if wrong usage

The commandline argument check in roster.py: A bit strange, I find whatever I am doing I can't get this error message to print, the function will shut down alright, but no error message, I have tried ...
0
votes
0answers
19 views

cs50 plurality wont accept the first candidate and gives a segmentation fault

the program compiles and seems to run as long as I dont vote for the first candidate. I can vote for the others then I get a segmentation fault. code as below include include include // Max ...
0
votes
1answer
18 views

Command-line validation key

I cannot figure out why am I getting these results? I'm currently only trying to validate the Numeric Key when typing 20x as a command-line argument get Usage: ./caesar Key #include <cs50.h> #...
0
votes
1answer
53 views

Pset3: Plurality; Code doesn't consider command line arguments expect the first one!

I don't understand why my code only considers the first command line argument and shows "Invalid Input" for rest of the arguments upon passing other argument's name while voting. Here is the code ...
0
votes
1answer
12 views

Arguments of the main function

I have a question about these two different mini-programs: #include <cs50.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> int main(void)...
0
votes
1answer
47 views

What does argc and argv have to do with cryptography? Why are we learning about these arguments?

I understand what these arguments do--take inputs before the program starts to in some way influence the program. But they seem to have been shoe-horned into the lecture. David moves on from this ...
0
votes
1answer
95 views

CS50 Vigenere Segmentation Fault

I'm stuck on this for days. I've also tried other answers on this question but still not able to understand what's causing Segmentation Fault when I enter a string as key after ./vigenere. Here's my ...
0
votes
1answer
263 views

PSET 2 Caesar: Help getting key from user (one line)

I am currently on CS50x’s PSET2, Caesar, trying to get a key from the user (the first step pretty much). I need to get the key from the user. I understand that it will be a string stored in argv2 and ...
0
votes
1answer
320 views

command line arguments help to use them in the program

I'm not sure how to include the input from the command-line arguement. I try to set the arguments equal to variables, bu it's not working. #include <stdio.h> #include <cs50.h> int main(...
0
votes
1answer
32 views

not satisfying the condition for input

In command line argument,it should not accept argv[1] as a numeric or any other.It should accept only alphabetic and that argv[1] is treated as key which is to be added with plaintext.so,for that i ...
0
votes
1answer
223 views

CS50 PSET2 code will not compile

I would appreciate any help that could be given with my code below (+ error codes below that): My code will not compile and the primary error apparently is an "undeclared identifier" refering to ...
0
votes
1answer
4k views

null pointer passed as argument 1

I had written this function for argument checking but it is showing this type of error vigenere.c:26:20: runtime error: null pointer passed as argument 1, which is declared to never be null /usr/...
0
votes
1answer
104 views

String validity check when string is command line argument?

We check the string validity when we use the get_string() function. Example: if (p != NULL) Are we also supposed to check string validity when the string is entered as a command line argument?
0
votes
2answers
93 views

Pset 2 - Vigenere Checking Command Line Input

I am working on the Vigenere portion of the pset and appear to have it totally working, yet when I ran the checker I realized that I had not created a test for non-alphabet characters in the command ...
0
votes
1answer
21 views

What is `all:` command?

I encountered a problem while using all command (or variable if : is used to create one) during problem set 3. bash: all:: command not found The context is building both generate and find (two files ...
0
votes
1answer
67 views

is `key` in `./caesar key` my second or third command-line argument?

I don't need help with the pset, since I have finished already. in caesar, I was getting a segmentation fault. after changing argv[2] to argv[1], the problem was solved. My question is: if I my ...
0
votes
1answer
87 views

Command Line Arguments - argc and argv[]

Since argc gives the number of command line arguments, which is the length of argv[] why should the square brackets be empty? Can I not write main function signature as int main(int argc, string argv[...
0
votes
2answers
53 views

Question on pset2 youtube video(command-line argument)

It is one of pset2 youtube video instruction about command-line argument. address is following, https://youtu.be/X8PmYwnbLKM In 6:56, it shows code like this. int main(int argc, char*argv[]) { for(...
0
votes
2answers
1k views

PSET5 Dictionary - error : Could not open texts files

I have a problem to open texts files related to pset5. I think that is nothing to do with my code. It's probably the way I ask in the command window or maybe my current directory. Is it the good way ...
0
votes
1answer
95 views

caesar.c command line argument not stored in argv

This is about Problem Set 2, week 3, caesar.c. My code doesn't store the int I get from the user via GetInt() in argv. Consequently, argc stays at value 1 and the one command line argument given by ...
0
votes
1answer
48 views

Can anyone give me an example of code without a command-line-argument and code with a command-line-argument?

After watching the lectures, walkthrough and notes of the lectures It is still not clear to me what purpose a command-line-argument got exactly. I hope if someone can give me an example of code with ...
0
votes
1answer
32 views

Main argument input definitions

Is it possible to use the main function to define what an input can be? int main(int argc, string argv[]) For example, within the argv[], the number of arguments can be defined to 1, 2, 3, etc. Can ...
0
votes
2answers
248 views

Command line argument - buffer over read

It was discussed one of the starting lectures that when using main method with command line arguments (int argc, string argv[]) then argv can be used to access memory location which is not intended to ...
0
votes
0answers
85 views

how to pass arguments to copy file program?

i am learning on study50 regarding file io. the exercise asks us to write a program to copy a file. I have written the code correctly for this program. I have named this cp.c and usage cp source ...
0
votes
2answers
240 views

Check50 message “Can't check until the frown turns upside down”

jharvard@appliance (~/Dropbox/pset2): ./caesar 13 Be sure to drink your Ovaltine! Or fher gb qevax lbhe Binygvar! This assignment required to execute like the above. However, if using int main (int ...
0
votes
2answers
54 views

Do I have to return a value when checking all command line arguments

When programming functions or checking command line arguments, is it necessary to return always return a value? For functions that are casted as an int, we must return 0 when the program runs and ...
1
vote
1answer
121 views

How do I ensure that the user input in greedy is given to two decimal places?

I have a question about 'Greedy' in pset1. How do I ensure that the input I'm given by the user is in the correct format, namely to two decimal places like 0.00?
0
votes
1answer
509 views

int GetInt(void) and command line arguments

Why don't the Get functions, GetString, GetInt etc, take command line arguments like the main function? It seems to me that they should since command lines are being inputed into the function.
0
votes
3answers
1k views

Segmentation Fault and Returning 1

If I declare int key before my if (argc != 2), I get a segmentation fault (core dumped) message when I run the program with only one command-line argument. However if I declared int key after the if ...