Sponsored Content
Top Forums Shell Programming and Scripting Passing argument 1 of 'scanf' makes po Post 302854015 by sgradywhite on Monday 16th of September 2013 02:39:58 PM
Old 09-16-2013
ok thanks now I have more errors with return that I want them to work.

I need the values to be found or not to be found in arrays.

Code:
Array.c: In function ‘main’:
Array.c:25: error: expected expression before ‘return’
Array.c:29: error: expected expression before ‘return’
Array.c: At top level:
Array.c:44: error: expected ‘)’ before ‘&’ token
Array.c:46: error: expected identifier or ‘(’ before ‘{’ token

Code:
#include "stdio.h" 
02#define MAXARRAY 12 
03#define MAXARRAY1 6 
04  
05int main() 
06{ 
07        int a[MAXARRAY]; 
08        int b[MAXARRAY1], 
09        nvals, 
10        nvals1; 
11        int size =0; 
12        size = sizeof(a)/sizeof(a[0]); 
13        printf("Array A has %d elements\n ", size); 
14        int size1=1; 
15        size1 = sizeof(a)/sizeof(a[0]); 
16        printf("Array B has %d elements ", size1); 
17        printf("Input the values in Array A"); 
18        nvals = get_data(a,MAXARRAY); 
19        printf("Input the values in Array B"); 
20        nvals1 = get_data(b, MAXARRAY1); 
21        int value; 
22        printf("Enter the value you wish to find in THREE arrays of floats"); 
23        scanf("%d", value); 
24        find_value(a,&size,&value); 
25        if (return == 0) 
26        printf("The value is found in Array A!"); 
27        else
28        find_value(b, &size1, &value); 
29        if (return == 0) 
30        printf("The value is found in Array B!"); 
31        else
32        printf("The value is not found!"); 
33} 
34int get_data(int vals[],int max) 
35{ 
36        int n = 0; 
37  
38        while (n < max && scanf("%d", &vals[n]) == 1) 
39        n++; 
40        return n; 
41} 
42  
43int find_value(array, &scale, &num) 
44int arrary[], scale, num; 
45{ 
46  
47        for (i = scale -1; i>= 0; i--) 
48        {       if ( array[i]==num ); 
49                { 
50                return 0; 
51                } 
52        } 
53  
54                return -1; 
55}

---------- Post updated at 02:39 PM ---------- Previous update was at 02:23 PM ----------

what kind of return statement should I use I still have problem with the returned???
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

passing argument into awk

i'm trying to pass a numerical argument with function xyz to print specfic lines of filename, but my 'awk' syntax is incorrect. ie xyx 3 (prints the 3rd line, separated by ':' of filename) function xyz() { arg1=$1 cat filename | awk -F: -v x=$arg1 '{print $x}' } any ideas? (4 Replies)
Discussion started by: prkfriryce
4 Replies

2. Shell Programming and Scripting

passing Argument

Hi All, i have script like below.. echo "1) first option" echo "" echo "2) second option" echo "" echo "*) please enter the correct option" read select case $select in 1) echo "first option selected" ;; 2) echo "second option selected" ;; *) echo "please enter the correct... (4 Replies)
Discussion started by: Shahul
4 Replies

3. UNIX for Dummies Questions & Answers

Using * when passing argument to alias

I have some folders with this structure: /data/me/a123xxx Where "xxx" is some changing series of letters, and "123" changes so folders might look like: /data/me/a123xxx /data/me/a234ysd /data/me/a534sds etc. The numbers are what matter to me (they identify the folder), so I created an... (7 Replies)
Discussion started by: ramparts
7 Replies

4. Shell Programming and Scripting

Passing argument to nawk

Hi all I have got a file digits.data containing the following data 1 3 4 2 4 9 7 3 1 7 3 10 I am writing a script that will pass an argument from C-shell to nawk command. But it seems the values in the nawk comman does not get set. the program does not print no values out. Here is the... (2 Replies)
Discussion started by: ganiel24
2 Replies

5. Programming

warning: passing arg 1 of `inet_addr' makes pointer from integer without a cast

I use solaris10,following is tcp client code: #include "cliserv.h" int main(int argc,char argv){ struct sockaddr_in serv; char request,reply; int sockfd,n; if(argc!=2) err_quit("usage: tcpclient <IP address of server>"); if((sockfd=socket(PF_INET,SOCK_STREAM,0))<0) ... (1 Reply)
Discussion started by: konvalo
1 Replies

6. Shell Programming and Scripting

passing argument from one function to another

Hi all, In the given script code . I want to pass the maximum value that variable "i" will have in function DivideJobs () to variable $max of function SubmitCondorJob(). Any help? Thanks #!/bin/bash ... (55 Replies)
Discussion started by: nrjrasaxena
55 Replies

7. Shell Programming and Scripting

passing argument in script?

hi, I want to implement some function to perform following task if ; then $TEXT = "Data_0" else $TEXT = $1 fi if ; then $Lines = 45 else $Lines = $2 fi Kindly suggest, thanks (11 Replies)
Discussion started by: nrjrasaxena
11 Replies

8. Shell Programming and Scripting

Help with passing argument

Hi, I have a script that is scheduled with cron and runs every night. The cron part looks like this: 00 20 * * 0,1,2,3,4,5,6 /usr/local/bin/BACKUP TBTARM HOT DELETE My issue is with the 3rd parameter. Somewhere in the script, i want to tell the script to delete some files if the 3rd... (7 Replies)
Discussion started by: dollypee
7 Replies

9. Shell Programming and Scripting

Argument passing

How to pass the alphabet character as a argument in case and in if block? ex: c=$1 if a-z ]] then echo "alphabet" case $1 in a-z) echo "the value is a alphabet" edit by bakunin: please use CODE-tags. We REALLY mean it. (9 Replies)
Discussion started by: Roozo
9 Replies

10. UNIX for Beginners Questions & Answers

Passing a second argument

I am trying to pass a second argument like so: if ] then export ARG2=$2 else message "Second argument not specified: USAGE - $PROGRAM_NAME ARG1 ARG2" checkerror -e 2 -m "Please specify if it is a history or weekly (H or W) extract in the 2nd argument" fi however, it always goes... (4 Replies)
Discussion started by: MIA651
4 Replies
Log::Dispatch::Array(3pm)				User Contributed Perl Documentation				 Log::Dispatch::Array(3pm)

NAME
Log::Dispatch::Array - log events to an array (reference) VERSION
version 1.001 SYNOPSIS
use Log::Dispatch; use Log::Dispatch::Array; my $log = Log::Dispatch->new; my $target = []; $log->add(Log::Dispatch::Array->new( name => 'text_table', min_level => 'debug', array => $target, )); $log->warn($_) for @events; # now $target refers to an array of events DESCRIPTION
This provides a Log::Dispatch log output system that appends logged events to an array reference. This is probably only useful for testing the logging of your code. METHODS
"new" my $table_log = Log::Dispatch::Array->new(\%arg); This method constructs a new Log::Dispatch::Array output object. Valid arguments are: array - a reference to an array to append to; defaults to an attr on $table_log array This method returns a reference to the array to which logging is being performed. log_message This is the method which performs the actual logging, as detailed by Log::Dispatch::Output. AUTHOR
Ricardo Signes, "<rjbs@cpan.org>" BUGS
Please report any bugs or feature requests through the web interface at <http://rt.cpan.org>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. COPYRIGHT
Copyright 2008 Ricardo SIGNES, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2008-04-29 Log::Dispatch::Array(3pm)
All times are GMT -4. The time now is 01:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy