473,326 Members | 2,061 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.

trouble in call my own function

i'm just a beginner in c++
my assignment was to wrote the functions.
i tried to write a main to test it.
but i could call it correctly/.
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4. using namespace std;
  5.  
  6. bool chars(char x)
  7.     {
  8.         if (((x<=90)&&(x>=65))||((x<=122)&&(x>=97)))
  9.             return false;
  10.         else return true;
  11.     }
  12.  
  13.  
  14. int transformCriteria(unsigned int distances[], std::string words1[],std::string words2[],unsigned int nCriteria)
  15. {
  16.     int z;
  17.     for (int i=0; i<nCriteria;i++)
  18.     {    
  19.         int s1= words1[i].size();
  20.         int s2= words2[i].size();
  21.         string originalWord1=words1[i];
  22.         string originalWord2=words2[i];
  23.  
  24.  
  25.         words1[i].erase(std::remove_if(words1[i].begin(), words1[i].end(), &chars), words1[i].end());
  26.  
  27.  
  28.         words2[i].erase(std::remove_if(words2[i].begin(), words2[i].end(), &chars), words2[i].end());
  29.  
  30.         for (int s=0; s<s1; s++)
  31.         {
  32.             words1[i][s]=words1[i][s]+32;
  33.         }
  34.         for (int s=0; s<s2; s++)
  35.         {
  36.             words2[i][s]=words2[i][s]+32;
  37.         }
  38.         if ((originalWord1!=words1[i])||(originalWord2!=words2[i]))
  39.             z++;
  40.     }
  41.     return z;
  42.  
  43. }
  44.  
  45. int main()
  46. {
  47.     string n1[3]={ "teacher", "teacher", "teacher2"};
  48.     string n2[3]={ "teacher11", "teacher", "teacher22"};
  49.     unsigned int q=3;
  50.     unsigned int p[]={2,3,4};
  51.     cout << transformCriteria(p[], n1[], n2[], q)<< endl;//here is where mistakes happen
  52. }
  53.  
  54.  
Feb 18 '13 #1

✓ answered by weaknessforcats

When you call transformationCriteria, the array is p and not p[]. You will need to fix the other arrays also in the call statement.

You are confusing the declaration of an array p[] with the actual array p.

2 1475
donbock
2,426 Expert 2GB
What errors did you observe?
Feb 18 '13 #2
weaknessforcats
9,208 Expert Mod 8TB
When you call transformationCriteria, the array is p and not p[]. You will need to fix the other arrays also in the call statement.

You are confusing the declaration of an array p[] with the actual array p.
Feb 18 '13 #3

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

Similar topics

5
by: Lucy Randles | last post by:
I've written a VBA function that I then need to call in a form. Previously to do this I have written the call procedure in the same module as the function - i.e. Function callfunctionname() Call...
2
by: PawelR | last post by:
Hello Group, In my application I have few class, and I want call function with "master class". This is as master form (startClass) and option window (ClassA). My question is how call function...
4
by: Dave | last post by:
I have a program that I've written a class for. I need to call the function in the program from the class. When I try to call the function I receive the error, the name xxx does not exist in the...
2
by: moondaddy | last post by:
I'm using vb.net and have an aspx page where I want to call a function in the code behind to do something on the backend and I want to call this function from a jscript function in the aspx page. ...
7
by: Tiraman | last post by:
Hi , I have 3 files , middle.aspx file include the header.aspx and footer.aspx files . in each of the include files there is a function and from some reason the call to the Footer() function...
12
by: leaf | last post by:
Hi, How to call function at runtime, based on a struct that contains the information for the function call: struct func_to_call { int function_id; // function id to call unsigned int nparams;...
5
by: yaru22 | last post by:
Hi. I'm wondering if there is a way to call function that a variable refers to. I was writing a script to load xml file. And what I've written so far looks like this: var xmlDoc; ...
1
by: Khai Doan | last post by:
I have function A, which need to call function B with the exact same argument list. What is the correct way to do this? I had function A: function A { B(arguments); } but it does not...
9
by: Andrew Poulos | last post by:
Say I have this: var foo = function(x, y) { return x + y; }; var bar = function(fname, param1, param2) { /* * how do I call the function "foo" * and pass parameters to it?
1
by: intermanch | last post by:
how call function php($varible) into javascript withod ajax: <!-- this code only call funnctions php but how call function php intermanch@gmail.com www.intermanch.blogfa.com
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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.