Visual C++ :: Finding Items (strings) In Multiple Lists

Mar 12, 2013

Im working on a script compiler and i need to handle different types of data. Actually different categories of items.

Let's say i have two categories: cat's and bird's. They are different and stored in different lists. And let's say there is a simple command: GIVE_FOOD_TO(animal_type, food_type) Animal type here can be either from birds category or cat's category.

And also let's say user gives command: GIVE_FOOD_TO(cat1, fish)
and also for example: GIVE_FOOD_TO(bird1, birdfood)

Variable names could be anything, but im storing each variable name in std::map so later i can figure out with what animal current command is used.

When im parsing the script then i must know if user supplied either cat or bird. If i just would have cat's or bird's category then i would have only 2 lists and not a big problem to loop through either cats list or birds list and find out in what list the "cat1" is or in what particular list the "bird1" is. It would be in one or another.

But i have a lot of categories and looping through all of these lists (or std::maps) is slow and doesn't seem like a good. Just to find out in what list it's stored. I can't rely on variable names, they could be anything.

Big picture atm:

1) I have one BIG box which stores all of the categories

2) When i need to find out to which category the variable (animal_type) point's to i must get it quickly, dunno, std::map in std::map or something?

What i need basically is: I have different lists (each one is just a category for either birds or cats in this example) And when i have variable name, i must find out quickly in what particular category this item is stored. So i can work with it.

View 4 Replies


ADVERTISEMENT

C# :: Finding The Size Of Multiple Lists

Sep 21, 2013

I am writing a Windows Form program, and currently it has 3 Lists. I need to loop through all three, and use each possible combination, so am using three nested for loops.

I found that if the outer loop had less elements than one of the inner loops/lists, some were missed off, as I need to save all the possible combinations of list a + b + c.

This is what I wrote:

Code:
public int CalculateOrderToProcessLists()//for three lists
{
int order = 0;
if (sListOne.Count() > sListTwo.Count() && sListTwo.Count() > sListThree.Count())
{
order = 123;

[Code ....

My problem is I would like to be able to have 4 (or more if possible) lists, and to calculate what order to process the lists will be exponentially more complex.

Any better way of comparing the sizes of the lists, so that I can use the nested loops of say 4 lists, but being able to use N number of lists would be awesome.

View 2 Replies View Related

Visual C++ :: How To Use CListCtrl For Show Multiple DialogBoxs Like Items In Icon View

Jan 15, 2014

i can write a mfc program to make a Thumbnail view with image but can not this when change image with CDialogBox.

Thumbnail view with image(chart) like this:

for (int i=0;i<10;i++) {
CChartContainer *cc = new CChartContainer();
if(cc->m_frmWin->Create(_T(""),
WS_CHILD|WS_VISIBLE|SS_BITMAP, rc,
this,idDyn)) {
}
}

how can i write mfc program to make a Thumbnail view of CDialogBoxs?

do i can use CListCtrl for show multiple DialogBoxs?

View 13 Replies View Related

C++ :: Using A Textbox And Other Items Between Multiple Forms

Oct 31, 2013

I am writing a program in Visual C++ 10 with 2 forms.

In the first form I have a textbox and a button. The button opens the second form.

In the second form, I have a button that changes the text in the textbox in form1 to an item from a listbox in form2.

Here is my problem. When I do the code for the button in form2 to change the textbox in form1 I get the errors:

error C2065: 'textBox1' : undeclared identifier
error C2227: left of '->Text' must point to class/struct/union/generic type

I thought maybe I should just include the "Form1.h" file but I can't do that because I already included "Form2.h" in form1 in order to be able to open the second form. If I try to include form1 in form2, it says that the code to open form2 is an error now.

My question is, how can I access identifiers such as "textbox1" from other forms and other files when I already used the first form to open the second form? I also want to know how to do this for all identifiers between all files.

how to print the selecteditem from a listbox into a textbox because that doesn't work by just setting them equal either.

Here is my code:

#pragma once
#include "Form2.h"
namespace Test1 {
using namespace System;

[Code].....

View 11 Replies View Related

C# :: Hotel Management App - Selecting Multiple Items

Jan 27, 2014

I'm writing a Hotel magmt app. I'm having difficulty on how to implement a hotel attendant selecting/secure multiple rooms(with nos) for a Customer using combobox or listbox or something. How my interface will look like and techniques.

View 1 Replies View Related

C# :: Find And Select Multiple Items In ListBox?

Apr 18, 2014

I have a listbox that retrieves a bunch of values. I'm able to selectAll, Select None and Select Individual items. I'm not able to search the ListBox and select based on String value.

I have tried creating a for and if loop, but it will only select a single item (first item) in my ListBox.

private void btnSelectCAD_Click(object sender, EventArgs e) {
// Find CAD Line Patterns that Begin with IMPORT:
string mySearchString = "IMPORT";
// Search Listbox starting from index -1:
int index = lstLinePatterns.FindString(mySearchString, -1);

[code]......

View 5 Replies View Related

C Sharp :: Comparing For Common Elements In Multiple Lists Using Intersect In C#

Mar 20, 2013

I have a dynamic number of lists coming in from a different method . i need to find out the common elements present in all of the lists .

How do i do it with intersect construct in C#.

Placing it in a loop gets me the elements common in the last comparison , but never gets me elements commong in all lists.

View 1 Replies View Related

C :: Finding Unique Strings Within A File?

Aug 10, 2014

I have been trying to write this program that reads a file of courses and then stores only the unique courses in an array of strings.

for some reason it crashes while reading the 2nd line.

printf within the function are just for me trying to trace the problem.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char** uniqueCourses(FILE *fp, int *wordCount);
int main()

[code].....

View 5 Replies View Related

C/C++ :: User Input Validation - Finding GCD And LCM Of Multiple Numbers

Oct 23, 2014

I need validation on what the user inputs. Input should not be an alphabet, empty, and not negative number. This program is for finding the GCD and LCM of multiple numbers.

#include <stdio.h>
void bubble_sort(int numbers[], int len) {
int i, j;
int swapped;

[Code] .....

View 2 Replies View Related

Visual C++ :: How Many Items Exist In A Dialog Box

Sep 11, 2013

I was wondering how can we know how many items exist in a dialogbox? If there any way that i can get the items ID in a dialogbox by having just the dialogbox's object or handler? Or any way that we can get a dialogbox content by coding.

View 6 Replies View Related

C++ :: Decipher Multiple Strings From TXT File

Nov 17, 2013

I need making a function that is deciphering multiple strings from a .txt file. The function is supposed to remove all instances of the first three characters from the string.

An example would be from l.pjkjsdfl.p[)sdfslkl.p ------> jkjsdf[)sdfslk

Basically it removes "l.p" from wherever it is in the string.

I am new to C++ and I don't know where to start from.

View 1 Replies View Related

Visual C++ :: Control For Owner-drawing Items With 1 Or 2 Columns?

Jan 22, 2014

I want to show a list of graphical items in 1 or 2 columns (user selected). I will draw the items (owner-draw). I tried many hours today to find a solution with clistctrl. Is it possible to make it with clistctrl?

View 14 Replies View Related

C++ :: Search A Vector Element With Multiple Strings?

Nov 22, 2013

How could I search a vector element with multiple strings

i.e. vector.at(i) = This is a test

How could I search that to look for the word "test" in that element?

View 7 Replies View Related

C++ :: Converting Multiple Lines Of Strings To Double

Aug 26, 2014

I am trying to convert multiple lines of strings to double with std::stod .... I used the code found on the website:

#include <iostream>
#include <sstream>
#include <string>
#include <fstream>
int main() {
std::string two_doubles =" 22145.365 -3564789";
std::string::size_type K;
double first = std::stod (two_doubles, &K);
double second = std::stod (two_doubles.substr(K));
}

The string starts with white spaces. I get this error message when compiling:

warning unused variable 'first'
warning unused variable 'second'

How do you convert the two numbers in the string two_doubles to doubles?

View 2 Replies View Related

C++ :: Enter Multiple Strings Into Char Array

Feb 16, 2014

I am having issues getting this working. This is a simple program that is designed to ask a user if he would like to enter a string, if yes, the user is prompted to enter it and its stored in a char array. User is then asked if he wants to enter another string... Once user responds no, the program outputs the strings and the program ends...

Note: I'm using in.getline(myarray[i], MAX, ' '), to avoid white space problems if user enters a space. Lastly I would like the option of letting user enter any number of strings, but how would you do this when declaring the 2 dimensional char array?

#include <iostream>
#include <string>
using namespace std;
const int MAX = 81; //max char is sting is 80
int main(){
string y_n;
bool go = true;

[Code] ....

View 2 Replies View Related

C++ :: Strings - Read Multiple Values In On A Single Line

Jul 28, 2014

My question is on c++ strings. At the moment my program is reading input in one line at a time after the user presses enter.

I want to read multiple values in on a single line. Example: "apple banana orange end" ... How would I do this?

MAIN Code:
#include "Header.h"
#include "Orange.h"
#include <iostream>
#include <string>
#include <cctype>
using namespace std;

[Code] ......

View 11 Replies View Related

Visual C++ :: Design Class Objects To Support Outlining Of Collection Of Items

Sep 9, 2013

I am struggling with how to efficiently design my class objects to support the outlining of a collection of items. The collection would be sorted but would also have the ability to indent and outdent individual items representing a Parent and Child relationship (see attached).

An item could indent up to 5 levels deep. A summary level would be considered a Parent while items below the summary level would be consider as children.

View 6 Replies View Related

Visual C++ :: Disable CCheckListBox Items Without Access To Code That Calls AddString

Apr 19, 2013

I need to be able to disable the items on a CCheckListBox but I can't change the code that calls AddString. I know I can use the CCheckListBox::Enable function to disable an item if I have an index but I don't have the index which would be provided by AddString.

I've tried intercepting the LB_ADDSTRING message and then looping through the items in the control but the string has not been added at this point so the last item in the list is never disabled.

I used Spy++ to see what messages were being sent and I noticed that LB_GETTEXT was sent so I tried intercepting this message (ugly hack) but this caused my app to hang - I assume because of the number of times the message is sent. Is there a way to disable the items?

View 10 Replies View Related

Visual C++ :: Random Lists Repeating

May 27, 2014

So I wanted to make a program which randomizes a list letters or something without repeating the letters like I get here:

Code:
#include <iostream>
#include <string>
#include <stdio.h> /* printf, scanf, puts, NULL */
#include <stdlib.h> /* srand, rand */
#include <time.h> /* time */
int main () {
using std::cout;
using std::cin;
using std::string;

[Code] ....

View 3 Replies View Related

Visual C++ :: Tool Tips Not Showing - Toolbar Menu Items Disabled / Inactive

Jan 8, 2014

My problem is ToolTips are not shown if any of the tool-bar menu items is disabled/inactive.

They are shown when all tool bar menus are active/enabled.

I am using TTS_ALWAYSTIP while creating Tool-Bar.

What to do to enable/display tool-tips always.

View 5 Replies View Related

C++ :: Reading From Console Multiple Strings Of Unknown Length In Combination With Integers

Oct 10, 2014

I want to read a string of unknown length from stdin. I tried to follow the approach from this link.

[URL]....

My code is like this:

Code:

#include <iostream>
#include <string>
using namespace std;
int n;
cin >> n;
cout << "The value of n is " << n << endl;
string str;
getline(cin, str);
cout << "The entereed string is " << str << endl;

What I have noticed is that if I take integer input from cin (cin >> n in the above code before getline, the control does not stop on getline to take str as input from the console. If I don't do (cin >> n) before getline then the control stops on getline and takes the string as input.

What is the best way to read from console multiple strings of unknown length in combination with the integers?

View 1 Replies View Related

Visual C++ :: Finding Temperature At The End Of Interval But Can't Seem To Get Answer?

Oct 30, 2013

I've been trying to get the numbers for hours now but i can seem to get it right. Here's the problem below:

During the initial period, when the heater is not yet functioning at peak efficiency the heating will increase the temperature inside the building at a rate given by the following equations. During the initial period when the air conditioner is not yet functioning at peak efficacy the air conditioner will decrease the temperature inside the building at a rate given by the same equations.

Interval = (Time since turning on / 2.0 ) - 3.0
Factor multiplying Temperature change per minute = exp( Interval) / ( 1 + exp(Interval) )

These equations can also be used after the heating or air conditioner reaches peak efficiency. These equations converge to 1, so after the heating or air conditioner reach peak efficiency these equations will always give a value of 1.

the value of these equations needs to be multiplied by the RATE TEMPERATURE CHANGES. The RATE TEMPERATURE CHANGES is EITHER the change in temperature inside the building in degrees Celsius per minute caused by heat being extracted by the air conditioning OR the change in temperature inside the building in degrees Celsius per minute caused by the heat being generated by the heating .Temperature change in degrees per minute = Factor multiplying Temperature change per minute * RATE TEMPERATURE CHANGES

Temperature at end of this interval = Temperature at the start of the interval + temperature change due to heat escaping during the this interval + temperature change due to heat generated by the heating system during this interval + temperature change due to heat removed by the cooling system during this interval

i have a:

...rate of -.05 for heat escape w/o cooling or heating
...rate of 0.10 for heat escape w/ cooling
...rate of 0.125 for heat increase w/ heating
...Starting temp=38.00
...Time interval 3.50

I can't seem to find the temp at the ending interval? What i tried doing:

Code:
#include<iostream>
#include<cmath>
using namespace std;
int main () {
double intervals=0.00;
double tempPerMin=0.00;

[Code] ....

The temperature at the end of the interval is suppose to be 37.81 but i can't get the answer. I'm pretty sure this is a logical error from the equations i used but i can't seem to find it.

View 3 Replies View Related

Visual C++ :: Error In Finding Lowest Double In Array

Oct 25, 2014

When I run the program, when it displays the lowest temtpature, it shows the address instead of the actual number.

Code:
/*********************************************
* File: b.cpp
* Description: Create a C++ program that declares a 100-element array of doubles representing temperature readings. Pass the array to a function to be partially filled by the user. When the user is done entering temperatures, the function should return the number of elements added to the array. The main function should then display the maximum and minimum temperatures in the array.
***********************************************/

#include <iostream>
using namespace std;
//prototypes
void getData(double arr[]);

[Code] ....

View 2 Replies View Related

Visual C++ :: Relationship Between Two Hex Strings?

Aug 19, 2013

I'm trying to make an application for ELM327 trouble code scanning device for my own educational purpose. Most of my app code is done. however, I am stuck at one point. And I need finding relationship between two hex strings.

I have logged some communication between ECU and a chinese code scanning device for carrying out car's fuel pressure test. However there is one message (that is sent from the user side) that keeps on changing each time which is dependent upon the last message received from the ECU which is also varying every time.

Code:
RECEIVED (07E8) SEND (07E0)
05 67 03 0C 17 6A 00 00 05 27 04 8F 45 37 00 00
05 67 03 0C DB 68 00 00 05 27 04 B0 70 6B 00 00
05 67 03 10 3B 87 00 00 05 27 04 3B BC 10 00 00

[code]....

as it can be seen 3 bytes are always changing with each test, both, in the message received from the ECU, and the one sent back to the ECU from the diagnostic scanner. Trying to figure out relationship between these two strings?

P.S: about 16 million combinations for 3 byte data are possible... there must be some link between them...

View 4 Replies View Related

Visual C++ :: Random Linked Strings

Feb 9, 2013

I want to make a funny and simple game in cmd with visual studio and here is my plan, here are the steps that I wanna accomplish:

The program asks the person for

1: 4 girl names
2: 4 boy names
3: What they do? (4 actions)
4: Where they do this? (4 locations)
5: Random linked things

And from here I want to randomly get 1 line of a random girl name + random boy name + random action + random place. and followed by the second, third, and fourth line of random chosen things.

Like this:
Girl 1 - Boy 3 - Action 2 - Location 4;
Girl 3 - Boy 4 - Action 4 - Location 1;
Girl 2 - Boy 1 - Action 3 - Location 3;
Girl 4 - Boy 2 - Action 1 - Location 2;

And it can get funny like: Amber and John are jumping from a bridge. a game where you can play with your friends and have fun.

Here is my code so far:

#include<iostream>
#include<string>
#include<ctime>
#include<cstdlib>
int main (void) {
using std::cin;
using std::cout;
using std::string;

[Code] ....

And from here I don't know what to do!!

View 3 Replies View Related

Visual C++ :: How To Access Argv Strings

Dec 22, 2012

I have:

int _tmain(int argc, char* argv[])
{
printf("drive name: %s
", argv[1]);

It displays only the first character of the first argument on the command line.

Yet the following works as expected:

static char* myArg[2] = {"first arg","second arg"};
printf("drive name: %s
", myArgv[1]);

That displays the entire string "second arg".

So what's wrong with my reference to argv[1]?

View 4 Replies View Related







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