Sponsored Content
Top Forums Programming Need help in storing command line argument argv[2] to a variable of int type Post 302267273 by jim mcnamara on Friday 12th of December 2008 04:16:26 AM
Old 12-12-2008
Code:
int iFilecount=0;
// later on in the code...
iFilecount=atoi(argv[2]);

P
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing the command line argument in a variable

Hi, I am new to unix. Is their a way to pass the output of the line below to a variable var1. ls -1t | head -1. I am trying something like var1=ls -1t | head -1, but I get error. Situation is: I get file everyday through FTP in my unix box. I have to write a script that picks up first... (1 Reply)
Discussion started by: rkumar28
1 Replies

2. Programming

Help - Cast converts default int return type

What does the warning message 724 "Cast converts default int return type to." tell me. I am new to C. (used it some in college). We are migrating our c-code to 10.2.0.3.0. The programs compiled clean. However there were several warning messages that kick out. The most prominent warning is: ... (5 Replies)
Discussion started by: rtgreen
5 Replies

3. Shell Programming and Scripting

storing result of a command in variable

For whatever reason I cant seem to fix my syntax to do the following. I want to run a grep and count how many instances come up and store that number in a variable but I keep erroring out. Here's my code in bash: number=grep blah file.txt | wc -l (1 Reply)
Discussion started by: eltinator
1 Replies

4. Shell Programming and Scripting

storing a command in a variable

how would i go about storing this command in a variable echo "$LINE" | awk -F"|" '{print $1"|"$2"|"$3"}' i have tried FOO = ${command up there} but receive the error FOO: not found aswell as a couple of other attempt but no luck (2 Replies)
Discussion started by: nookie
2 Replies

5. Shell Programming and Scripting

Using ARGV, acepting text from command line

I want to be able to call in my file and make it do it's magic by basically giving it: FileNAME.pl searchTerm fileToSearch It runs, and gives me the answers I want, however, it gives me an error: Can't open GAATTC: No such file or directory at .//restriction_map_better.pl line 15... (2 Replies)
Discussion started by: silkiechicken
2 Replies

6. Shell Programming and Scripting

Storing o/p of a command to a variable

Hi, I have a ftp script there I want to store the o/p of the below command: sftp -b <batch file> user@password cat <batch file> get /remote/file/path/remote_file_name.csv*.gz /local/path Now the problem is that when I fire this command. Then it gives o/p as: File... (7 Replies)
Discussion started by: dips_ag
7 Replies

7. Shell Programming and Scripting

Pass command line argument to variable

Hi, I had written a shell script to pass command line argument to variable in a function. Here is my code: main if ; then .$1 echo $1 get_input_file else echo "input file $1 is not available" fi get_input_file() { FILE = "$1" echo $FILE } (10 Replies)
Discussion started by: Poonamol
10 Replies

8. Programming

Splitting string and storing in int

I have a string containing 2 integers separated by /, for example 12/8 or 8/6 am want to store the numbers in two integers. (3 Replies)
Discussion started by: kristinu
3 Replies

9. Shell Programming and Scripting

Storing command output in a variable and using cut/awk

Hi, My aim is to get the md5 hash of a file and store it in a variable. var1="md5sum file1" $var1 The above outputs fine but also contains the filename, so somthing like this 243ASsf25 file1 i just need to get the first part and put it into a variable. var1="md5sum file1"... (5 Replies)
Discussion started by: JustALol
5 Replies

10. Shell Programming and Scripting

Storing awk command in a variable

I'm working on a script in which gives certain details in its output depending on user-specified options. So, what I'd like to do is something like: if then awkcmd='some_awk_command' else awkcmd='some_other_awk_command' fi Then, later in the script, we'd do something like: ... (5 Replies)
Discussion started by: treesloth
5 Replies
ATOI(3) 						   BSD Library Functions Manual 						   ATOI(3)

NAME
atoi, atoi_l -- convert ASCII string to integer LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <stdlib.h> int atoi(const char *str); #include <xlocale.h> int atoi_l(const char *str, locale_t loc); DESCRIPTION
The atoi() function converts the initial portion of the string pointed to by str to int representation. It is equivalent to: (int)strtol(str, (char **)NULL, 10); While the atoi() function uses the current locale, the atoi_l() function may be passed a locale directly. See xlocale(3) for more informa- tion. IMPLEMENTATION NOTES
The atoi() and atoi_l() functions are thread-safe and async-cancel-safe. The strtol() and strtol_l() functions are recommended instead of atoi() and atoi_l() functions, especially in new code. ERRORS
The function atoi() need not affect the value of errno on an error. SEE ALSO
atof(3), atol(3), strtod(3), strtol(3), strtoul(3), xlocale(3) STANDARDS
The atoi() function conforms to ISO/IEC 9945-1:1990 (``POSIX.1''), ISO/IEC 9899:1990 (``ISO C90''), and ISO/IEC 9899:1999 (``ISO C99''). BSD
June 4, 1993 BSD
All times are GMT -4. The time now is 01:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy