473,326 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

question on function and passing it an array

question on function and passing it an array
this is what i have so far and im getting errors.....


Expand|Select|Wrap|Line Numbers
  1.  int dup_mark(int a, int b[]);
  2.  
  3.  int scores[20];
  4.  int value;
  5.  
  6.  
  7.  
  8.    cout << "Enter list: ";
  9.  
  10. int i;
  11.    for( i = 0; i < 20; i++) {
  12.            cin >> value;
  13.            if(value == 0) {
  14.                     break;
  15.            }
  16.            scores[i] = value;
  17.         }
  18.            int n = i; //save i because that is the number of process we need.
  19.  
  20.         //getting input is done
  21.  
  22.         dup_mark(n,scores[]);
  23.  
  24. int dup_mark(int a, int b[])
  25. {
  26.  
  27.  for(int dup_loop = 0;dup_loop < a; ++dup_loop)
  28.         {
  29.         for(int dup2 = dup_loop+1; dup2 < a; ++dup2)
  30.         {
  31.         if (b[dup2] == b[dup_loop])
  32.         {
  33.             b[dup2] = 0;
  34.         }
  35.         }}}
if anyone can help I would appreciate it
Apr 11 '07 #1
1 1176
horace1
1,510 Expert 1GB
when you call the function
Expand|Select|Wrap|Line Numbers
  1.         //getting input is done
  2.         dup_mark(n,scores[]);
  3.  
you don't need the [], e.g.
Expand|Select|Wrap|Line Numbers
  1.         //getting input is done
  2.         dup_mark(n,scores);
  3.  
Apr 11 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: its me | last post by:
Let's say I have a class of people... Public Class People Public Sex as String Public Age as int Public Name as string end class And I declare an array of this class...
3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
8
by: kalinga1234 | last post by:
there is a problem regarding passing array of characters to another function(without using structures,pointer etc,).can anybody help me to solve the problem.
21
by: Gerry Abbott | last post by:
Hi All, If completed a script which parses a string into fragments (fields), then assigns these substrings into an array. I wish to turn this into a function to which i can pass the string....
52
by: junky_fellow | last post by:
char *str1 = "Hello"; char arr1 = { "Hello" }; char arr2 = { 'H', 'e', 'l', 'l', 'o' }; Is it legal to modify str1, arr1 and arr2 ?
5
by: RKS | last post by:
I am new to Com programming using C++. Can pointers be passed through interface functions. I would like to pass multi dimensional arrays to functions defined in the com interface. Any help is...
24
by: Michael | last post by:
Hi, I am trying to pass a function an array of strings, but I am having trouble getting the indexing to index the strings rather than the individual characters of one of the strings. I have...
28
by: Larax | last post by:
Best explanation of my question will be an example, look below at this simple function: function SetEventHandler(element) { // some operations on element element.onclick = function(event) {
6
by: bahoo | last post by:
Hi, I have an array that I need to define inside a function, and later use it in another function. main() { Object* arr = NULL; func1( arr );
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.