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 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 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.
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'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 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??
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?
the code use in above link is good but one problem i cant able to use backspace to remove mistake if user made any mistake he cant able to remove the mistaken character
this is really important i searched an example code about "Username and Password Validation between Server and Client" through internet a LOT and i couldn't find anything..
"How to create login id and password" because i have to submit this assignment next weeks i dont know how to using passing by value or reference corectly/
For the Ouput its say this :
1>ClCompile: 1> GILA DAH!!.cpp 1>d:computer programmin ditg 1113jiwa ku sakitjiwa ku sakitGILA DAH!!.cpp(21): error C2664: 'strlen' : cannot convert parameter 1 from 'char' to 'const char *' 1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast 1> 1>Build FAILED.
Ive been working on a program that can mask the password and has 3 attempts. So far I can't do both at the same time. Here is my work. How can I do both?
#include<iostream> #include<string.h> #include<conio.h> using namespace std; int main() { string _pass; char input;
I wanted to make an program which is sending messages to log in and password, but instead of message it gives me "System.Windows.Forms.TextBox, Text: AND HERE MY TEXT I WANTED.
How to make a program to enter password and if password right I can change the curency. I only want to change from ringgit malaysia to us dollar.The program can convert currency many times.I only want to use stdio.h
#include <stdio.h> void main() { int pass; printf("Input your password"); scanf("%d",$pass); if (pass==4782)
[Code] ....
After this what should I put to complete this program?
Okay, so I have a science fair project and I decided on doing a series of programs that show the simpleness behind hacking a password. Each program increases in complexity starting with a four digit password, and ending with a 10 digit letter and number combo that is case sensitive. Right now I need to figure out a way to have my program be able to convert chars into ints, so that I can do a counter and then I also need to be able to convert the ints, back into chars.
I am trying to create a login that accepts a user login and password. it should accept 3 tries in which when the user enters their username the system should tell whether if the username is correct if not it should display a message saying invalid username and directs the user to register like entering their dob and name. But I cannot seem to get this part run correctly.
#include<stdio.h> #include<conio.h> #include<stdlib.h> #include<string.h> void main() { char userId[10]; char passwrd[10]; int p = 0;
So I need to make a program that recieves a 10 letter only password, then once the password is entered, it starts off as AAAAAAAAAA...AAAAAAAAAB...AAAAAAAAAC...etc, Until it gets the correct password, which it then stops. This is for a science fair project on cyber security not for malicious purposes ...