[CS241C-01@lewis ~]$ cc Array.c
Array.c: In function ‘main’:
Array.c:23: warning: passing argument 1 of ‘scanf’ makes po
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 ‘{’ to
[CS241C-01@lewis ~]$
ok so this is the problem I got. I am trying to input the value to search the value in the array and I don't know what went wrong. Help me.
Code:
login as: CS241C-01
CS241C-01@148.166.200.55's password:
Last login: Mon Sep 16 10:36:56 2013 from ool-addcc5ab.static.optonline.net
[CS241C-01@lewis ~]$ vi Array.c
#include "stdio.h"
#define MAXARRAY 12
#define MAXARRAY1 6
int main()
{
int a[MAXARRAY];
int b[MAXARRAY1],
nvals,
nvals1;
int size =0;
size = sizeof(a)/sizeof(a[0]);
printf("Array A has %d elements\n ", size);
int size1=1;
size1 = sizeof(a)/sizeof(a[0]);
printf("Array B has %d elements ", size1);
printf("Input the values in Array A");
nvals = get_data(a,MAXARRAY);
printf("Input the values in Array B");
nvals1 = get_data(b, MAXARRAY1);
int value;
printf("Enter the value you wish to find in THREE arrays of floats");
scanf(value);
find_value(a,&size,&value);
if (return == 0)
printf("The value is found in Array A!");
else
find_value(b, &size1, &value);
if (return == 0)
printf("The value is found in Array B!");
else
printf("The value is not found!");
}
int get_data(int vals[],int max)
{
int n = 0;
while (n < max && scanf("%d", &vals[n]) == 1)
n++;
return n;
}
int find_value(array, &scale, &num)
int arrary[], scale, num;
{
for (i = scale -1; i>= 0; i--)
{ if ( array[i]==num );
return 0;
}
else
return -1;
}
see if you can help me with this code thanks!
---------- Post updated at 01:50 PM ---------- Previous update was at 01:38 PM ----------
how do I use input in code? do I use "scanf"? and then put the assigned integer variagle next to one like this scanf(number) or scanf"number"? please help!
Last edited by Scrutinizer; 09-16-2013 at 02:58 PM..
Reason: additional code tags
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)
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)
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)
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)
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)
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)
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)
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)
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
LEARN ABOUT SUSE
tap::parser::iterator::array
TAP::Parser::Iterator::Array(3pm) Perl Programmers Reference Guide TAP::Parser::Iterator::Array(3pm)NAME
TAP::Parser::Iterator::Array - Internal TAP::Parser array Iterator
VERSION
Version 3.17
SYNOPSIS
# see TAP::Parser::IteratorFactory for preferred usage
# to use directly:
use TAP::Parser::Iterator::Array;
my @data = ('foo', 'bar', baz');
my $it = TAP::Parser::Iterator::Array->new(@data);
my $line = $it->next;
DESCRIPTION
This is a simple iterator wrapper for arrays of scalar content, used by TAP::Parser. Unless you're subclassing, you probably won't need to
use this module directly.
METHODS
Class Methods
"new"
Create an iterator. Takes one argument: an $array_ref
Instance Methods
"next"
Iterate through it, of course.
"next_raw"
Iterate raw input without applying any fixes for quirky input syntax.
"wait"
Get the wait status for this iterator. For an array iterator this will always be zero.
"exit"
Get the exit status for this iterator. For an array iterator this will always be zero.
ATTRIBUTION
Originally ripped off from Test::Harness.
SEE ALSO
TAP::Object, TAP::Parser, TAP::Parser::Iterator, TAP::Parser::IteratorFactory,
perl v5.12.1 2010-04-26 TAP::Parser::Iterator::Array(3pm)