FAQ Database Discussion Community


How do I pass an integer into the pthread_create function from argv? (C)

c,casting,pthreads,argv
For this program I pass in numbers through the command line and then have a multithreaded program that takes each argument, calculates its factors, then prints them. I know c++, but I'm rough with c and can't seem to get the casting down correctly for this program. Specifically when I...

How declare function to pass one argument argv[i] at a time? In C

c,pointers,argv
While debugging when I jump to function parseLayerFile filename is (char **) 0x40a04e <_Jv_RegisterClasses+4235342>... How to correct the declaration to get valid filename value? void parseArgs(WRAPPER_t *w, int argc, char *argv[]) { int i; for (i=1 ;i<argc ;i++) { if (strcmp(argv[i],"-layers") == 0) { i++; parseLayerFile(argv[i]); } } // for...

Python argv and cmd

python,argv
I'm trying to make a Python program that can correct exams automaticly, I have extra time and don't wanna wait for my teacher to correct them manually... Annyways when i use python argv like this: import sys def hello(a): print(a) a = sys.argv[1:] hello(a) And i want to insert a...

Using arg[v] as int? - Objective C

objective-c,xcode,argv
I'm trying to pass arguments into and integer variable at the start of my program in xcode using Objective C. So far most methods I've found have just given me a variety of error messages or crashed my VM. int numcols, numrows; int main(int argc, const char * argv[]) {...

How to get python interpreter full argv command line options?

python,argv,werkzeug
As we know from documentation: -c If this option is given, the first element of sys.argv will be "-c" and the current directory will be added to the start of sys.path (allowing modules in that directory to be imported as top level modules). How can I get full interpreter command...

Am unable to combine gets.to_i with ARGV arguments, in Ruby [duplicate]

ruby,argv
This question already has an answer here: Why is gets throwing an error when arguments are passed to my ruby script? 2 answers So, I just learned about ARGV and the arguments, and I'm trying to combine gets.to_i (or gets.chomp) in the same script. But it ain't happening. Any...

How do I make a function print out a certain amount of Random numbers through the command line? C

c,random,command,argv,argc
How do I pass an arguement and print that amount of numbers in my program? So far I have found out that if I change count to a lower number than argc, the amount of numbers increases. However, I want it to print x amount of numbers on whatever I...

How to turn *argv[] into a string inside isaplha

c++,argv
New to programming C++ and am having an issue with using isaplha to recongnize and display an error message when an argument is a letter. A, A1, and any combination of alpha-numerals starting with a letter displays an error, how ever 1a will pass as containing no letters. My code...

how do i take unlimited sys.argv[] arguments?

python,parsing,python-2.7,command-line-interface,argv
To elaborate, I am interested in learning how to code out in python a sys.argv[] function that allows the user to supply as many arguments as the user wants. I am unsure on if there is a better way to do this or if it can be done at all....

Learn Python The Hard Way - Exercise 13 Study Drills

python,terminal,argv,raw-input
In Learn Python The Hard Way (Exercise 13) the 3rd Study Drill says to "Combine raw_input with argv to make a script that gets more input from a user." I wrote this script below, intending to have the terminal prompt the user for answers to three questions, then it would...

Tcl $argc and $argv variables

variables,tcl,global,argv,argc
I'm kinda new to tcl but I have to write a proc that looks like this: proc TestVerb { Data Data_txt } { VERBATIM [format "// Data: $Data - $Data_txt"] if { $argc == 2} { VERBATIM {// SUCCESS //} else { exit 1 } I call the proc like...

Python - for fi in sys.argv[1:]: argument list too long

python,bash,arguments,argv
I am trying to execute a python script on all text files in a folder: for fi in sys.argv[1:]: And I get the following error -bash: /usr/bin/python: Argument list too long The way I call this Python function is the following: python functionName.py *.txt The folder has around 9000 files....

Why are execv*() arguments inconsistent with execl*()?

c,exec,standards,argv
Why are the argv arguments for the execv*() family of functions char * const [] whereas the execl*() family of arg0...n args are const char *? Is this just a mistake in the standard, and it should be const char * const [] or is there a reason for the...

C assign string from argv[] to char array

c,arrays,expression,variable-assignment,argv
I have the following code which reads an file name from the command line and opens this file: #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv){ FILE *datei; char filename[255]; //filename = argv[1]; //datei=fopen(filename, "r"); datei=fopen(argv[1], "r"); if(datei != NULL) printf("File opened"); else{ printf("Fehler beim öffnen von %s\n", filename);...

Beginner Python: save output file as argv input filename

python,filenames,argv
I want to save my generated plot with the same name as the input file. The input is through the command line, so I'm not really sure how to do it. #!/usr/bin/python import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from numpy import arange,array,ones#,random,linalg from pylab import plot,show from scipy import...

Use Commands from argv to Initialize a Global Mutex

pthreads,global-variables,global,mutex,argv
What I wish to do is to define a global mutex using data from argv. Not a problem, except that I also want this mutex to be global. This isn't global:: int main (int argc, char **argv) { int arg_1 = atoi(argv[1]); pthread_mutex_t mutex[arg_1]; return 0; } And this isn't...