Visual C++ :: Compare Two Strings To See Difference In Int Form

Apr 2, 2013

I want to compare two string, and want to see differeince in int form. For example,

Code:
string first_string="0002AE1";
string second_string="0002AE2";

How can i calculate difference between two string? It is obvious difference between above two string is 1/-1, but difference would be 1.

View 2 Replies


ADVERTISEMENT

Visual C++ :: Procedure To Compare 2 Strings With Specific Criteria?

Jul 10, 2013

Procedure to Compare 2 Strings with the following criteria

coding of the following function -

I have absolutely no clue where to start -

Given the following sets of numbers -

1154 1179 2154 2554 2484 2144 4515 1144 1517 4815 1481

Given the Index number of 1154

I want to search the numbers for the Index number of 1154

The search will return a True if I can find 3 or 4 same digits between the Index number and the 8 numbers

The search also have the following criteria -

meaning that -

1154 when compared to 1154 == true
1154 when compared to 1179 == false
1154 when compared to 2154 == true
1154 when compared to 2554 == false
1154 when compared to 2484 == false
1154 when compared to 2144 == false
1154 when compared to 4515 == true
1154 when compared to 1144 == true
1154 when compared to 1517 == true
1154 when compared to 4815 == true
1154 when compared to 1481 == true

the index number can also be of type - 1234, 1123, 1112, 1111

View 14 Replies View Related

C++ :: Compare Date And Show Difference In Days

May 20, 2012

I have a file, 'date-list.txt' which has date in it. For example , 20 May 2012 .

Now I want to compare this date with current system date and show the difference in days .

How can i compare dates and shows difference in days in C++.?

View 5 Replies View Related

C++ :: Difference Between Strings And Arrays?

Apr 10, 2013

What is the diff between strings and arrays? Here is sample:

By String:

#include <iostream>
#include <string>
using namespace std;
int main () {
string mystr;

[Code] .....

By arrays:

#include <iostream>
using namespace std;
int main () {
char name[256], title[256];

[Code] ....

which is preferable and can i pick characters one by one in string?

View 2 Replies View Related

C++ :: Compare Two Strings Of Numbers

Jan 4, 2014

I am trying to figure out how to go about comparing two strings of numbers. I have two files that both contain numbers 1-50, one file has multiple repeating numbers while the other one just has 1-50.

I want to compare the files and count how many of each number a occurred and make a chart with * next to the number. First I figured I would use the strings like an array and compare them using nested loops. Then I noticed I have single and double digit numbers. The numbers in the files are printed as:

1 44 5 34 4
2 22 7 55 4
...... etc

Compared too:
1
2
3
4
5
......
50

I thought about using string stream and converting the string to int but wouldn't it just be a huge number when set to the int variable? Then I thought about a array initialized with 1-50 and compared to the file but I still have the issue with single and double digit numbers.

My question is how can I just read one number at a time, either double or single digit?

View 11 Replies View Related

C++ :: Can't Compare Char Strings

Jun 13, 2013

I have two char* that have the same data in (hypothetically).

std::vector<char*> Buff;
Buff = Split(Line, '.');
char* A = "data", B;
B = Buff.at(0)

Where Split is a function that I made to split a string (Line in this case) into a char* vector, this string contains a line from a file. Line is char* too. The weird problem is when Buff data stored in its 0 position is given to B... because B is equal to A (hypothetically) but when this is compared to do certain functions they doesn't match!

Here an example:

std::vector<char*> Buff;
Buff = Split(Line, '.');
char* A = "map", B;
B = Buff.at(0) // Buff.at(0) should be "map" and is apparently "map"

[Code].....

NOTE: I didn't use switch to compare Cmd because I want it separately for easier debugging.

Is there something wrong with my codes?? or what happened here with those hex values before the string in my variables?

View 6 Replies View Related

C++ :: Rules To Compare Two Strings Object

Sep 1, 2014

In my book I have the following example : Code:

std::string str = "Hello";
std::string phrase = "Hello world";
std::string slang = "Hiya"; and i have these two rules to compare 2 strings object :

if two strings have different lenghts and if every character in the shorter string is equal to the corresponding character of the longer string, than the shorter string is less than the longer string.

if any characters at corresponding positions of two strings differ, then the result of the string comparison is the result of comparing the first character at wich the strings differ then my book says : if we apply the rules of the comparison we know that phrase is greater than str( ok i've understood this ) and that slang is greater than both slang and phrase ( why ?)

explain me rule number two ? in phrase and slang the characters differ and the first character that differ is not H so why my book says slang is bigger than phrase ?

View 3 Replies View Related

C++ :: Compare Two Strings To See Which Comes First In Alphabetical Order

Oct 14, 2013

How would you compare two strings in an if statement to determine which comes first in alphabetical order?

Try and keep it simple because i am currently new to the language

View 2 Replies View Related

C++ :: Compare 2 Dates From Strings / Char Or Int

Mar 16, 2014

i have been trying to compare a date format from SYSTEMTIME and a date from a text file(string).But its not working. I tried to change both to string(using osstringstream),char* and int(using sscanf) to do the comparison but with no luck. its pretty simple all i want to do is get the current system date and compare it with the date from the text file. Below is my code:

char szcurrentDate[MAX_PATH] = "";
char szdate_time[MAX_PATH];
SYSTEMTIME st;
GetLocalTime (&st);
GetDateFormat(LOCALE_USER_DEFAULT,NULL,&st,"yyyy-M-d ",szcurrentDate,MAX_PATH); //current system date
//std::ostringstream mm;

[code].....

note : i tried displaying just szcurrentDate and szdate_time they show the date exactly the same. in string,char* or int formats.

View 2 Replies View Related

C/C++ :: How To Compare Strings Ignoring Case

Oct 29, 2014

It should report whether or not, ignoring case, they are the same.

#include <stdio.h>
#include <string.h>
using namespace std;

[Code].....

View 1 Replies View Related

C :: Compare 2 Strings And Print Out 1 If Characters Match And 0 If Not

Oct 29, 2014

This program is supposed to compare 2 strings and print out a 1 if the characters match and a 0 if they dont. It compiles but doesnt give me the correct output.

Code:
#include <stdio.h>
#include <string.h>
void func();
int main () {
func();
return 0;

[Code] ....

View 11 Replies View Related

C :: How To Compare A String With A Set Of Strings That Have Been Stored In A File

May 5, 2014

I am trying to compare a string that i have entered with a set of strings that have already been stored in a file. I am using strcmp function but i am not getting the result.

Code:
printf("
Enter string:");
scanf("%s",&m);
ptr_file =fopen("abc.text","r");

[Code] .....

View 10 Replies View Related

C++ :: Read All Values / Strings Form Unknown File

Nov 4, 2014

For an assignment I have to write a program which basically converts 8 bit binary numbers to ASCII and outputs the assembled text. Here's the catch:

The 8-bit binary numbers are provided by some external file (which only contains 8 bit binary numbers); the name and hence length is not known. The external file is called with a pointer upon execution

(./"conversion program" < external_file.in).

I'm getting the 8 bits as a string, calculate/convert decimals, output char type. HOW do I know when to stop the loop? If I just pick an insanely high number I get random stuff at the end; no boundaries obviousely lead to an infinite loop. Can I determine the lenght of this random ext file somehow nonetheless?

Is it possible to create a vector which dynamically adjusts itself until there are no more strings = end of the file?

View 6 Replies View Related

Visual C++ :: Difference Between Double And Int64

Jul 31, 2013

1) What is the range of numbers covered by a 64-bit double?

2) Ignoring fractions, is the above range wider or narrower than the range covered by an int64?

View 14 Replies View Related

Visual C++ :: Compare Two Histograms In OpenCV?

Mar 5, 2013

I am tying to compare two histograms, but it gives error. Here I have given my code, histogram file and error message. Histogram file 3*5 matrix(output_test.txt):

1 2 3 4 5
5 2 1 4 2
2 1 2 4 2

code:

Code:
int main(..........)
{
................................................
Mat first_histogram(1,feature_vector_size, CV_32F);
Mat second_histogram(1,feature_vector_size, CV_32F);

[Code]....

Error message: error LNK2019: unresolved external symbol "double __cdecl cv::compareHist(class cv::Mat const &,class cv::Mat const &,int)" (?compareHist@cv@@YANABVMat@1@0H@Z)

View 1 Replies View Related

Visual C++ :: Working With More Than One Form?

Sep 27, 2012

I'm currently trying to work with more than one form, but I didn't succeed yet. What I need is quite simple: Once the program runs, a small form appears first asking "what would you like to do" with corresponding buttons for each option. Each button loads a new different form for a different task. So basically I need to open and close forms, also having two forms loaded at the same time (pop-up style) would be great for certain purposes.

I still haven't figured how to do it properly. I'm currently using VC++ 2008 and my project is a Windows Forms Application.

View 5 Replies View Related

Visual C++ :: How To Pass Value From One Form To Another

Mar 12, 2013

i am trying to create a form app with multiple forms. there is a form i'm using as "search". i want to take the value of the textbox in search-form and pass it to another form which shows the result of the search. i've tried to include search-form.h in the form of the result but it returns an error.

Code:

String ^ key;
key = searchbox->Text;
std::string ks = marshal_as<std::string>(key);
ks=ks+".bin";
ifstream sfile(ks);
if (sfile) {
PatInfo ^ form = gcnew PatInfo;
form->ShowDialog();
} else {
MessageBox::Show( "Please try again.");
}

to conclude, i want the form PatInfo to open an receive the "ks" var.

View 4 Replies View Related

Visual C++ :: Developing A Form Application?

Jan 15, 2014

I have a HTML code and i need to developing a form application.

issue: i have a html code and a database table , how to put this together with code and link them and peu them on server ...

View 3 Replies View Related

Visual C++ :: Allow User To Enter A Value As C String In Certain Form

Oct 14, 2013

My program was to allow the user to enter a value as a C string in the form: xxx,xxx,xxx,xxx,xxx.xx, where x can be any digit. Well, so far here is my attempt. I think the question is, would I have to implement a switch statement for the digits, the comma, and the decimal, so that when a user inputs, let say 52,000.00 the switch statements would read the 1st digit, checks for decimals/commas and if not, proceed to read 2nd digit, and repeat?

Code:
#include <iostream>
#include <string>
int main() {
using namespace std;
char buffer[256];
char tempBuff[256] = {'

[Code] ....

View 3 Replies View Related

Visual C++ :: Converting Code To CLI Form Application?

Jun 10, 2013

As a starter project I want convert a Neural net app from "AI Techniques for Game Programming (2002 Buckland)" to a Visual C++ CLI Forms application. I have created the interface and now I have to rewrite the in/output routines, amongst other things.

First question I have has to do with variable initialization used by Buckland. Code looks like this:

Excerpt from header file (CNeuralNet.h):

//-------------------------------------------------------------------
//define neuron struct
//-------------------------------------------------------------------
struct SNeuron
{
//the number of inputs into the neuron
int m_NumInputs;
//the weights for each input
vector<double>m_vecWeight;

[code]....

Question I have: what is the the function of ": m_NumInputs(NumInputs+1)" after the method declaration? Buckland does this in many places in his code. In this case it's a struct, but he does it with classes too.

View 3 Replies View Related

C Sharp :: Create Instance Of Form Into Non Form Class To Access Button / Label

Nov 23, 2014

I have a non form class. I want to update label/ check status of check box etc.. in non form class ( here resides functions that contains logic). How can i do that ?

View 4 Replies View Related

Visual C++ :: Windows Form - Create Method With Parameters

May 16, 2013

I am wanting to separate the logic from the visual, but I'm having problems when calling the method that controls the actions of the progress bar timer.

Code:

ifndef PROGRESS_BAR
define PROGRESS_BAR
class Progress_bar{
public:
void set_Progress(ToolStripStatusLabel^ label,Timer^ time){

[Code] ....

The way that I'm calling this method on Form1.h

void set_Progress(toolStripStatusLabel1 ,timer1);

Errors:

Error1error C2182: 'set_Progress' : illegal use of type 'void'h:cry_devprogrammingc++school_mediaschool_mediaForm1.h277
Error2error C2078: too many initializersh:cry_devprogrammingc++school_mediaschool_mediaForm1.h277
Error3error C2440: 'initializing' : cannot convert from 'System::Windows::Forms::Timer ^' to 'int'h:cry_devprogrammingc++school_mediaschool_mediaForm1.h277

View 3 Replies View Related

Visual C++ :: Create Window Form Function Using MFC Or Win32 API?

Jan 7, 2013

My setup is as follows:

There is function written C++, that must be compiled to DLL. This DLL is linked to some CAD (computer aded design) tool, that has special interface for it.

I want to add to this function some GUI (graphical user interface). So the creation of a window is necessary.

I've tried already with Win32, but without success.

The problem is that CreateWindow function requires application instance handle, that is provided by Windows itself when window is created in "normal conditions".

View 14 Replies View Related

Visual C++ :: Declaring Member Variables In Windows Form App

Sep 30, 2014

I have created a windows form project in visual studio so that I can use a windows form to interact with the game class that I'm creating, but I'm running into some problems.

For one thing, I would like to be able to call Image::FromFile() one time only during initialization, and store the result in a member variable (called mBGImage). From what I can tell, the variable needs to be of type String^ (this caret symbol is new to me, but I understand it is the "managed code" version of the standard pointer, which would look like String*).

When I try to compile the following code (located in my header file) I get the error :

"error C3265: cannot declare a managed 'mBGImage' in an unmanaged 'BSG::BSGame'".

How can I store the result of Image::FromFile() permanently in my class?

When I try to declare a global variable of type "Image^", I get "error C3145: global or static variable may not have managed type System:rawing::Image ^"

#include "stdafx.h"
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;

[Code] ......

View 2 Replies View Related

C# :: How To Access User Control Form One Of The Child Form

Apr 22, 2014

I hav created mdi parent form that contain one user control. I want to access that user control from one of the child form

View 4 Replies View Related

C# :: Login Then Close Form And Open Main Form

Aug 25, 2014

This is more of a Application Design question, Let's say I have Form1(Login), this is opened from Program.cs, when the user enters details, the Event Handler makes a instance of a class, adds the data and stores the instance within Program.cs class.

So the best thing to do here, is to close the Form1(Login) and open Form2(Main) via Program.cs so that I can send the List<Login> object with my Login instance objects to said form. This form will remain open throughout the applications use as it's like the main GUI for all the programs functions.

When I close this form, I may want to save some information before the application is terminated, so I may as well store the Login instances in Program.cs anyway.

Main stepping stone: Multiple (usually around 3 max) users can login this system if need be, which will mean closing Form2(Main) and then opening Form1(Login) so that once Form1 is closed it can recreate the From2(Main) form and pass the new List<Login> to that form.

What's the best way to do this, at the moment i'm creating the Form2 instance like so:

//....
//Detect the Login form being closed
loginForm.Closed += new EventHandler(OnLoginClosed);
//...
//Open the main form when the login is closed
private void OnLoginClosed(object sender, EventArgs e)

[Code] .....

This seems like it will work and do the job, but is there a better and cleaner way? The List<Login> will be passed to Forms which are created via Form2(Main) as this information will be needed. It's just that ive been told not to use Forms for too much data containment.

View 2 Replies View Related







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