C++ :: Seller Array - Error When Trying To Use Strcmp Function

May 1, 2014

I'm having an error when trying to use the strcmp function. Here's the jist of the code I'm working with:

Code:
class Seller
{
public:
Seller();
Seller( char [], char[], char [], double );

[Code] ....

I'm getting a
"[Error] cannot convert 'Seller::getID' from type 'char* (Seller:: )()' to type 'const char*'"
on this line of code:
"if (strcmp(sellerArray[i].getID, sellerArray[j].getID) < 0) "

How do i have this method able to compare these values in my seller array? Granted, there is more to the code and things actually in the seller array at this point. Is there something I'm not seeing??

View 4 Replies


ADVERTISEMENT

C++ :: Strcmp Function - Comparing String Data From Two Different Files

Dec 20, 2013

I am having a slight issue with the strcmp function. I am comparing string data from two different files. I want the function to output a set of information if the strings are the same and a different set of data if the strings are different. My issue is, the function outputs the data that's the same but not different.

I had an else statement that compared the data if it was NOT equal but it only duplicated the data in the file.

One file is a listing of 100 books with 10 lines of information and an assigned market. The second file is a listing of the markets contained in the books file. However, the books file has a market that is not located in the markets file. The "missing" market is what is not priting or displaying.

// final project2 file

#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>

using namespace std;
const int ARRAY_SIZE = 500;
const int MARKET_ARRAY = 6;
ifstream infile, infile2;
ofstream outfile;

[Code] .....

View 6 Replies View Related

C/C++ :: Error While Passing 2D Array To A Function

Nov 23, 2014

I'm trying to pass an 2d array to a function, but i'm getting this error message:

Error: 'p' undeclared here (not in a function)

#include <stdio.h>
void regStock(int stock[][p], int a);
int main( ) {
int a, p;
scanf("%d", &a);
scanf("%d", &p);

[Code] .......

View 6 Replies View Related

C++ :: Passing Array To Function - Error C2664

Jun 8, 2013

I've been trying to work fix this piece of code to put into a project but I could not get it to work. I keep getting this error C2664: 'SumOfNumbers' : cannot convert parameter 1 from 'int' to 'double []' . I've worked every thing piece by piece but when I try to pass the array to the function I get the error and don't know what it means. Does C++ not allow what I'm trying to do?

Code:
#include <iostream>
using namespace std;
void SumOfNumbers(double Nbr[], int size);
int main()

[Code] ....

View 7 Replies View Related

C :: Modify Value Of Whole Array By Passing It To A Function - Invalid Lvalue Error

Sep 23, 2013

i want to modify value of whole array by passing it to a function and make each value of array multiplied by 3 ,return the value to main and print it using pointer.

error : invalid Lvalue is the error

Code:

#include<stdio.h>
main()
{
int i,arr[10];
for (i=0;i<=9;i++)
{
printf("Enter value of arr[%d] : ",i);
scanf("%d",&arr[i]);

[Code] ....

View 1 Replies View Related

C/C++ :: Two Array Member Pass As Parameter - Expression Syntax Error For Function

Nov 8, 2013

In my project, GreedyKnap::calKnap(int nItem, int nCapacity, float fWeights, float fProfits);

This function include two array member pass as parameter. how can i do this?

View 1 Replies View Related

C :: Comparing Password With Strcmp

Oct 7, 2013

I'm a novice with C programming and i have to solve an error in the following code. The code works like you enter a password called "uoc" and it shows as OK. But surprisely when you entered another password as "Cambridge" it works fine too.

I think that the problem is in the array declaration but i'm checking resources and no success!

Code:
#include <stdio.h>
#include <string.h>
struct {
char str[8];
char ok;
} data;

[Code] ......

View 3 Replies View Related

C :: Strcmp Of 2 Multidimensional Arrays

Aug 6, 2014

I have used strcmp before on one dimensional arrays but not 2 dimensional arrays.The problem is that I have one 2d array that has text with some misspelled words and I have to compare it to another 2d array and if the word from the first array (misspelled word) is not in the 2nd array then I print it to the screen instead of correcting the spelling. Here is what I have so far:

Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int read_dic(char [], char [][20]);
int read_words(char [], char [][20]);
void typo_check(char *, char *);
}

[code]...

View 5 Replies View Related

C :: Searching Word Using Strcmp

Nov 15, 2014

I'm trying to write function that finds wheter the searched word exists or not. The compiler gives warning. Where is my wrong ?

|21|warning: passing argument 1 of 'strcmp' makes pointer from integer without a cast [enabled by default]|

Code:

#include <stdio.h>
#include <string.h>
int main ()
{
int result;
char arr[]="sakir emmim evde mi evde mi dedik lan";
int size=sizeof(arr)/sizeof(char);
char key[20];
scanf("%s", &key);

[Code]...

View 6 Replies View Related

C :: Strcmp Return Value On Different Compilers

May 3, 2013

I'm having a problem with the strcmp return value. My compiler returns the correct value based on my research, but I tried to compile the code below on those online compilers and the result was 1.

My compiler gave me 10, which I consider to be the correct result according to strcmp - C++ Reference. So strcmp is not very portable?

Code:
#include <stdio.h>
#include <string.h>

int main(void) {
printf("Return value: %d
", strcmp("Rocks", "Rockie"));
return 0;
}

View 6 Replies View Related

C++ :: Comparing Two Strings With Strcmp

Jun 22, 2014

I have trouble comparing two strings with strcmp. The bold part of the code are the parts that are not working and i hope somebody can explain to me what i did wrong. Goal of the code is to compare a city name with the name of already created cities and when two of them match to creat a Street between them. Depending on the street pointer different streets can be created

my vector containing all already created cities (it seem to work)
std::vector<city*> citylist;//all cities

find city using strings and creating a road between them:

bool Map::add_street(Street *street, const string firsttown , const string secondtown) {
city* hilfs1=Map::find_city(erste);
city* hilfs2=Map::find_city( zweite);
if (hilfs1==NULL || hilfs2==NULL)
{return false ;} // Problem :both pointers are always NULL

[Code] ....

Here is also my implementation of the getname function :

std::string city::getname() {
return this->name;
}

View 2 Replies View Related

C :: Strcmp Negative Value From User Input

Jul 24, 2014

I am studying c and I thought what would be better than using my pi to play with relays and c. I am used to PHP as a scripting lang and don' t do much programming. So I wrote this to use wirepi and ask the user "on or off" they type on or off and it does it. it does work but I know something is wrong when I use strcmp in the if statment I can -10 for a value. Here is the code.....

Code:
#include <stdio.h>
#include <string.h>
main(int argc, const char * argv[]) {
char oo[100];
system("gpio mode 0 out");
printf("Do you want it on or off?

[Code] ....

This is what it outputs at the prompt

Do you want it on or off?
on
on

It is now on!

How can I just get Code: if (oo = on) {} and like so with off.

View 2 Replies View Related

C++ :: Boost Binding - Comparing String Using Strcmp

Jun 5, 2014

I am trying to compare strings (char*) using strcmp but I am having a hard time doing it with boost::bind. It compiles but it crashes when I run it.

I have a std::vector<boost::shared_ptr<DeviceInfo>> cMonitoredDevices and one cCurrentDevices. I used a typedef DeviceContainer for std::vector<boost::shared_ptr<DeviceInfo>>.

DeviceInfo is a simply struct that contains a char[128] Name (and other fields not important for this issue) that I want to use to compare.

So I am trying to find the DeviceInfo (based on Name) that are in cMonitoredDevice but not in cCurrentDevices. My problem is retrieving the Name value for the strcmp. Here is what I have so far

for(DeviceContainer::iterator pDevice = m_cMonitoredDevices.begin();
pDevice != m_cMonitoredDevices.end(); pDevice++) {
if (std::find_if(cCurrentDevices.begin(), cCurrentDevices.end(),
boost::bind(&strcmp, boost::bind(&boost::shared_ptr<DeviceInfo>::value_type::Name, _1),
(*pDevice)->Name) == 0) == m_cMonitoredDevices.end()) {
}
}

View 2 Replies View Related

C :: Passing Arg 1 Of Strcmp Makes Pointer From Integer Without Cast

Jan 18, 2015

Code:

#include <stdio.h>
int main(){
int a=15 ;
int b =20 ;
strcmp((a, "20") == 0) {
printf("Correct!");

[Code] .....

passing arg 1 of `strcmp' makes pointer from integer without a cast

View 11 Replies View Related

C++ :: Strcmp On Linked List Data And String Constants?

Sep 28, 2013

why strcmp() doesn't return true when comparing a string constant with a string that was acquired via a linked list. By the way, the data in the linked list was taken from a text file. Does that imply that there's a new line () character in the string from the linked list?

Code:
struct Node{
char ACNO[15];
struct Node *next;

[Code]....

View 1 Replies View Related

C++ :: Syntax Error In Function Call - Type Mismatch In Parameter In Function Sort

Jul 6, 2014

error says "cannot convert 'int*' to 'int' in function main()
and also
type mismatch in parameter in function sort(int,int)

Heres the code:
#include<iostream.h>
#include<conio.h>
void main() {
void sort(int,int);
clrscr();

[Code] .....

View 11 Replies View Related

Visual C++ :: Error C3867 Function Call Missing Argument List For Calling Thread Function

Mar 19, 2013

I searched the web for error: C3867... and the discussions where murky or obscure.

My code excerpt is:

#pragma once
#include <windows.h>
#include <stdlib.h>
#include <process.h>
void PutUpfrmIO(void *);
namespace WordParsor {

[Code] .....

I get the generic message:

error C3867: 'WordParsor::Form1::PutUpfrmIO': function call missing argument list; use '&WordParsor::Form1::PutUpfrmIO' to create a pointer to memberc:userskingc++wordparsorwordparsorForm1.h... and the suggestion fix generate another error.

One person suggested the gcroot<> object wrapper... but I do not know how to modify/declair the function or its argument type.

View 2 Replies View Related

C :: Error Going In A Function

Jul 2, 2013

I have no error compiling, but running my project it stops before entering a function and debugging I have an error about Segmentation fault. The function:

Code:
1
2
3
4
5
6
7
Mat logGabor(matriz filter,Mat filter,double r_o,double theta_o,double sigma_theta, matriz radius,matriz theta,int cols,int rows,double sigma_r,int *padSize){

[Code]....

View 5 Replies View Related

C++ :: Error Entering A Function?

Jul 2, 2013

I have no error compiling, but running my project it stops before entering a function and debugging I have an error about Segmentation fault. The function:

Code:

Mat logGabor(matriz filter,Mat filter,double r_o,double theta_o,double sigma_theta,
matriz radius,matriz theta,int cols,int rows,double sigma_r,int *padSize){
Mat rpad;
int k=*padSize;
printf("Welcome to the function"); //Here the error
...

More info: I created the matriz as : typedef double** matriz;
and a createmat function that give back a double** and in this function I allocate space for matriz and works. In the main:

Code:
Mat chr-Rpad[4][5]; //chrOrient=4;chrScales=5
for(int i_or=1;i_or<chrOrient;i_or++){
for(int i_sc=1;i_sc<chrScales;i_sc++){
//some math calculation
chrRpad[i_or-1][i_sc-1]=abs(logGabor(filter,imftt2,r_o,theta_o,sigma_theta,radius,theta,cols,rows,sigma_r,padSize));

View 6 Replies View Related

C/C++ :: Getting Error Name Function Should Have Prototype

Aug 25, 2014

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main() {
int i=1,j=2;
float k,l=1.5;

[Code] ...

View 3 Replies View Related

C++ :: 0xC0000005 Error When Calling A Function

Sep 12, 2013

I'm new to C/C++. I'm trying to make a program that's going to use the CBLAS libraries that I downloaded on BLAS. After fighting tooth and nail with VC 2005 (I downgraded on purpose because at one point I was desperate.) with regards to solving compilation errors and such and eventually it all compiled just fine.

The problem now is, I get the above mentioned error. It says: "Unhandled exception at 0x0040271c in Try.exe: 0xC0000005: Access violation reading location 0x4e18feb8."

Now there are a few .cpp files (I'm compiling as C code.) which contain the functions and there is one other one which contains my main method. Using the debugger, it goes through 3 files all in all.

The main file: Code: /* cblas_example2.c */

#include <stdio.h>
#include <stdlib.h>
#include "cblas.h"
#include "cblas_f77.h"

[Code] .....

I get the above-mentioned exception in the last line, or:

Code: cblas_dgemm( UNDEFINED, transa, transb, *m, *n, *k, *alpha, a, *lda, b, *ldb, *beta, c, *ldc );

The debugger tells me what the address in the exception is the address if *ldc.

View 6 Replies View Related

C++ :: Error When Translating Function From Matlab To C

Jul 1, 2013

I have en error translating a function from Matlab to C/C++ :

Code:
radius(floor(rows/2+1),floor(cols/2+1)) = 1;
% Get rid of the 0 radius value at the 0
% frequency point (now at top-left corner)
% so that taking the log of the radius will
% not cause trouble.

What I did is:

Code: radius[rows/2][cols/2]=1;

I m sure it s there the problem, because before this line I can print what I want and I can see it at run-time, but after this line I can not print nothing and the work is like blocked. Do you know the error?

View 7 Replies View Related

C :: Passing Values To A Function Error

Apr 29, 2014

I'm working through the Let us C book. One exercise asks me to collect int and float , then pass them to a function that gets product of these and returns it to main. My code looks like this:

Code:

#include <stdio.h>#include <stdlib.h>
main()
{
int a;
float b, c;

[Code]...

So while compiling i get an error about conflicting types for product. I tried to google that error but couldn't understand what's the problem. My only clue is that i can't pass int and float to a function at the same time... Could that be it?

View 6 Replies View Related

C :: Signal Function Defined Twice With No Error?

Dec 13, 2013

I'm using a library in my code in a file called "my_signal.c". In this file I've defined this function:

Code:
Sigfunc * signal(int signo, Sigfunc *func){
struct sigaction act, oact;
...
}

Since the signal function is also in file signal.h and I included it in "my_sygnal.h" file, I'm wondering why the compiler did not say anything about this "double declaration" of the function with the same name.

View 9 Replies View Related

C++ :: Inaccessible Error In Inherited Function

Nov 6, 2013

THis is my small program i am getting error CPP 46: 'result::putdata()'is not accessible

#include<iostream.h>
#include<conio.h>
class stud
{

[Code]......

View 1 Replies View Related

C++ :: Identifying Error In Factorial Function

Apr 8, 2014

double expression(int n, double x) {
double num=(pow((x),2*a));
double den=fact(n,a);
double sum=0;
for(int a=0; a>=0; a++)
sum=pow(x,n)*(num/den);
return sum;
}

I don't know why this isn't working. fact is a factorial function which I have tested and it works fine. But when I input, for example:

int main() {
cout<<expression(1,3)<<endl;
getch();
return 0;
}

it comes up with an error.

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved