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?
I am working on extending an application that features a (rather old) plugin system. The plugin system is designed to work on x86 only, but support any and all compilers on windows, linux and also OSX.
My goals are now to
1) extend the plugin framework in a backwards compatible way 2) port it elegantly to x64
So far so good.
The plugin subsystem essentially exports a bunch of SDK function like this:
Code: extern "C" CDECL int somefunc(int a, int b);
Which can be used by the plugin, and expect the plugin to export some function in return. When a struct is supposed to be send to the plugin, the syntax of the system goes like this:
Code: extern "C" CDECL int RequestStructField(int field, int structhandle);
So the struct isnt handed over via a pointer, but every field has to be requested individually! From what I can tell from the comments, the developer was afraid there might be problems exchanging structs between different compilers, alignment and all.
I would like to tear down this limitation, and pass pointers to structs to plugin directly. Or better: allow the plugin to give me a pointer to an empty struct which i subsequently fill.
However, i have no control over the compiler or language used to write the plugins. Quiet some plugins are written in Delphi, some even in MASM ... both would have to support this way of passing structs.
the question is: does that work?
I have looked at other plugin systems, but they either use entirely different ways (XPCOM) or are limited to a single platform or compiler.
Some of them have a note stating that the plugin must be compiled with "byte-aligned" structs.
x86 and x64 plugins are two different stories, x64 version of the app does NOT have load x86 plugins. I dont expect there to be too man problems (right?). But we'll see, i guess.
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!
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:
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);
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 :
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.
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??
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
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.
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?
I'm writing some functions pertaining to binary trees. I've used recursion once before while learning quicksort but am still quite new and unfamiliar with it. And this is my first time touching a binary tree. So my question: In my addnode function, will the return root statement at the end ever return a value other than the value passed to the function?
#include <iostream> using namespace std; int n; int& test();
[Code] ....
Explanation
In program above, the return type of function test() is int&. Hence this function returns by reference. The return statement is return n; but unlike return by value. This statement doesn't return value of n, instead it returns variable n itself.
Then the variable n is assigned to the left side of code test() = 5; and value of n is displayed.
I don't quite understand the bold sentence. Shouldn't value of n and variable n be the same?
In my program below, in the getage and get level functions, if an incorrect input is entered, then the correct one is entered after, it still returns the bad input back to main.
myClass is a class I have. Now, in the class, I have a function what_value and I need to get the classes.at(0) from the pointer to it in another function. But the problem is, how can I do it? I'm completely stumped, here's what I thought of:
newClass.*myclass.what_value();
And it I get an error from the compiler. Basically, how can I do this in another function with a pointer:
I'm going to write a program that takes string until end of file(eof). An condition must be considered and that is it must also terminate by a new line. For example when it's prompting me to enter a string if I press enter it must terminate and exit the program. How is it possible? I tried saving carriage return("") as a string then I compared it with the entered string but it didn't work.
So the task is to find the node with minimum value of a binary tree (not binary search tree). the input is the pointer to the root of the tree. and i cannot make recursion work when i do if conditions. here is what i have Code: /*function 3-takses as input the pointer to the root of the tree and returns a pointer to the node with the minimum value*/
CPPtr minimumvalue(CPPtr SP){ CPPtr min = NULL; //node of minimum value if(SP== NULL){ // if there is a node, begin comparing return NULL; } else{ if(SP->data<SP->left->data){ //if the node has smaller value than its left child min = SP; //update node of minimum value
[code].....
no matter where i call my function i get errors like unhandled exception at some memory. how to use recursion in this?
Is this even syntactically correct? It gives me errors. Im just trying to compile it without errors. I think the function makes sense since its returning a type Class