Visual C++ :: Map With Two Key Values?

Mar 29, 2013

I have an assignment where I need to go through all the files in a folder. For each file I need to know each unique file extension, how many files for each unique file extension, and the total size for each unique file extension. I have to be able to sort through this using either the file extension or the total size of the file extension. The first thing I thought of using was a map. This will keep track of each unique file extension and the amount of times that file extension was found. How do I now associate the total size of the file extension to my map? So for example I need the output to be something like this:

Using file extension for sort
.cpp : 1 : 3400
.exe : 3 : 3455600
.mp4 : 25 : 200000404

Using total file extension size for sort
.mp4 : 25 : 200000404
.exe : 3 : 3455600
.cpp : 1 : 3400

Here is the code I have so far:

Code:
#include <iostream>
#include <filesystem>
#include <map>

[Code]...

I was thinking of somehow using a class to implement this, but don't know how to go about doing that. A

View 1 Replies


ADVERTISEMENT

Visual C++ :: Comparison Of 2 Double Values

Dec 27, 2013

I have std::vector of players and each player have its own value. The value is of the type double, but the original value are of the "XX.00".

Now what I'm trying to do is to insert a player into this vector. For that I need to find a place and to find a place I need to compare player value.

So lets say I have a player in the vector whose value is 24.00 and I am trying to insert a player whose value is 25.00. To my surprise MSVC 2010 tells me that:

24.0000000000000 == 25.00000000000

I do aware that comparing double type is not going to work like this, but I would expect not to have such big of a difference. ;-)

Why this comparison is true and how to eliminate such thing?

View 3 Replies View Related

Visual C++ :: Giving Values To All The Members?

Oct 15, 2013

Write a C++ program to implement the following description:

1. Define a global structure and name it GStruct with the following members:
a. X as integer
b. Y as integer.

2. Define a local structure inside the main and name it LStruct with the following members:
a. X as integer
b. Y[3] as GStruct

3. Inside the main declare two variables V1 and V2 of type LStruct.

4. Give values to all of their members by using input statement (cin).

5. If V1 equal V2 print "They are equal" else print "Not Equal".

#include <iostream>
using namespace std;
struct GStruct {
int x;
int y;
};
int main() {

[Code] .....

View 1 Replies View Related

Visual C++ :: Find All Variables And Their Values

Oct 13, 2014

In the following code I want to iterate through "Win32_OperatingSystem" to find all variables and their values. Using GetNames() I can get the names of all the variables but the subsequent Get() call fails to return a value.

Code:
//connect to WMI
std::wstring wmiClass = L"Win32_OperatingSystem";
CComPtr< IWbemLocator > pLocator;
HRESULT hResult = pLocator.CoCreateInstance( CLSID_WbemAdministrativeLocator, nullptr, CLSCTX_INPROC_SERVER );
if ( SUCCEEDED( hResult ) )

[Code] ....

View 12 Replies View Related

Visual C++ :: Create Histogram From A Set Of Values In OpenCV?

Mar 9, 2013

I have a text file which consist of several values. These values represent distance from origin to any point in the triangle. How can I create histogram from these values? Is there any functions in OpenCV which can create histogram from these values? Below my sample values are given:

..........................

3.4 1.2 6.9 0.2 5.1 2.9

........................

View 1 Replies View Related

Visual C++ :: Assigning Values To And Extracting Them From A Vector

Nov 28, 2012

I am writing a program to play rock paper scissors, and I am trying to get a vector to store the result of a given round of play, and output it as a declaration as to who won. I can't figure out how to store the values in the vector properly, and how to use the vector as an argument to output the result of play.

Code:
#include <iostream>
#include <iomanip>
#include <ctime>
#include <vector>
#include <cstdlib>
#include <string>
using namespace std;
const string name[4] = {" ", "rock", "paper", "scissors"};
const string roundResult[3] = {"computer win", "player win", "tie"};

[Code]....

View 1 Replies View Related

Visual C++ :: Read And Write Values Into File?

Sep 22, 2012

correct the below code:

file already contains entries : 1st row username; 2nd row password.

check status required to write at third line and need to read or alter the check status value.

Currently this code is working if already there is a value for check status, then it is overwriting else UI hanging.

Code:
WriteCheckStatusToFile(BOOL& locVar) {
FILE *l_pFile = NULL;
CString l_strRememberCheck;
l_strRememberCheck = GetExePath() + _T("password");
CString sVar;
sVar.Format(_T("%d"),locVar);

[code]....

View 2 Replies View Related

Visual C++ :: Hex Values From Stream - Unicode Settings?

Feb 18, 2014

I am using VC++ 2005, Multibyte char set. I am getting hex values from stream and i have to show it in respective language.

in below example

char mt[] = { 0x0C, 0x85, 0x0C, 0x86, 0x0C, 0x87,0x0C, 0x88,0x0C, 0x89, 0x0C, 0x8A,0x0C, 0x8B,
0x0c, 0x85 , 0x0c , 0x86 , 0x0c , 0x87 , 0x0c , 0x88 , 0x0c , 0x89 , 0x0c , 0x8a , 0x0c , 0x8b , 0x00 , 0x20,
0x0c, 0x8e , 0x0c , 0x8f , 0x0c , 0x90 , 0x0c , 0x92 , 0x0c , 0x93 , 0x0c , 0x94 , 0x00 , 0x20 , 0x0c , 0x95,
0x0c, 0x96 , 0x0c , 0x97 , 0x0c , 0x98 , 0x0c , 0x99 , 0x00 , 0x20 , 0x0c , 0x9a , 0x0c , 0x9b , 0x0c , 0x9c,
0x0c, 0x9d , 0x0c , 0x9e , 0x00 , 0x20 , 0x0c , 0x9f , 0x0c , 0xa0 , 0x0c , 0xa1 , 0x0c , 0xa2 , 0x0c , 0xa3,
0x00, 0x20 , 0x0c , 0xa4 , 0x0c , 0xa5 , 0x0c , 0xa6 , 0x0c , 0xa7 , 0x0c , 0xa8 , 0x00 , 0x20 , 0x0c , 0xaa,
0x0c, 0xab , 0x0c , 0xac , 0x0c , 0xad , 0x0c , 0xae , 0x00 , 0x20 , 0x0c , 0xaf , 0x0c , 0xb0 , 0x0c , 0xb2,
0x0c, 0xb5 , 0x0c , 0xb6};

How can i convert the mt string to below string?

"ಅಆಇಈಉಊಋ ಎಏಐಒಓಔ ಕಖಗಘಙ ಚಛಜಝಞ ಟಠಡಢಣ ತಥದಧನ ಪಫಬಭಮ ಯರಲವಶ"

To cross check the mt array, If you place the above string to the below link you get mt array [URL] ....

Cant i do it in "Multibyte char set" settings? or should i use Unicode settings.

View 3 Replies View Related

Visual C++ :: Display Values Of 2-dimensional Array

Aug 31, 2013

1.Create one 2-dimensional array. The array will consist of numbers from 1 to 10. And will also contain the number in words. Display the values of the 2-dimensional array.

Sample output:
1 - One
2 - Two
3 - Three

Paste the program code here:

2.Create a program that will accept two integer numbers. These integer numbers will be the limit of the multiplication table. Store the values in a two dimensional array.

Sample output:
Enter x: 3
Enter y: 2
123
246

Paste the program code here:

3. Determine the output produced by the following program segment.

int ROWS = 3;
int COLS = 4;
int [ ] [ ] val = {{8,16,9, 52},{3,15,27,6},{14,25,2,10}};
for (int i=0; i < ROWS; i++) {
for (int j= 0; j<COLS; j++)
System.out.print (val [i][j] + " " );
System.out.println ();
}

Write the Output:

View 6 Replies View Related

Visual C++ :: Program Must Accept 7 Values Or Stop It When Type S

Oct 27, 2014

I want to fix this code. The program must accept 7 values or stop it when you type s. The code not only couts the element, but also some other random numbers.

Code:
#include<iostream>
using namespace std;
int main() {
int numb[7];
int i;
char s;
for (i=0;i<=6;i++)

[Code] .....

View 2 Replies View Related

Visual C++ :: Class For Storing Values Inside XML File

Oct 9, 2014

In VC++ is there any inbuilt class for storying values inside an XML File, without using CLI?

View 14 Replies View Related

Visual C++ :: How Simplicity Read Text File Which Contain One Or Three Values

Oct 21, 2012

Text file can conain one or three integer values in string. How correctly and simplicity read this string?

View 1 Replies View Related

Visual C++ :: Reading And Writing Values From Excel Spreadsheet

Jul 31, 2013

I just got a job programming a windows application. One of the requirements is reading and writing values from an excel spreadsheet. Looking online, it appears that C++ isn't the best (one of the worst?) languages for reading and writing values from excel files. Now the language I'm most familiar with is C++ and I've been looking at C#, and it appears to be much easier to read excel files.

View 8 Replies View Related

Visual C++ :: Arrays - Solve Equation Using All Volume Values

Dec 22, 2012

I am using matlab R2o11 in which the programming medium is c++. I am having these variables=

T=373 t0 376
V=0.09 to 1
P=T/V

I just need a result showing ... First it should take T=373 and solve the equation using all volume values. Then it takes another temperature and do the same.

View 4 Replies View Related

Visual C++ :: Reading CSV File - Show Values In List?

Dec 26, 2012

I have problem reading CSV file, i found many solutions but i still got one problem. I need to read CSV file and then these values show in List Control and here i have problem. Idk how to display it in List?

View 4 Replies View Related

Visual C++ :: Program Doesn't Accept Input Values True?

Nov 1, 2014

I am making a program which is going to print out a head image according to the input values entered by the user. Here is the code:

Code:
#include <iostream>
#include <string>
using namespace std;
void Sides()
// draws the sides to take proportion

[Code] .....

At first i tried to work program like:

Code:
cout << "plase enter which way you want to print out the head, with parted hair or bald." << endl;
cin >> headstyle;
if (headstyle != "bald" || headstyle != "parted hair" )

But it also had given the same mistake. The program compiles BUT; even if I put in the values bald or parted hair the program prints out "wrong input" then exits.

View 2 Replies View Related

Visual C++ :: Program To Display Values From Data File As Image?

Jul 29, 2014

I am writing a program to display values from a data file as an image. But I can only get a blue screen. Here is a small program resembling my code. what I have missed? I only changed OnDraw function.

Code:
void CColorDisplayView::OnDraw(CDC* pDC) {
CColorDisplayDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
CRect rect;

[code].....

View 10 Replies View Related

Visual C++ :: GetMost And GetLeast Functions Returning Erroneous Values

Apr 5, 2014

After compiling, I cannot understand why my getMost and getLeast functions are returning erroneous values. I've done everything I could think of to try and fix this, Problem and code below.

A local zoo wants to keep track of how many pounds of food each of its three monkeys eats each day during a typical week. Write a program that stores this information in a twodimensional 3 * 7 array, where each row represents a different monkey and each column represents a different day of the week. The program should rst have the user input the data for each monkey. Then it should create a report that includes the following information:

* Average amount of food eaten per day by the whole family of monkeys.
* The least amount of food eaten during the week by any one monkey.
* The greatest amount of food eaten during the week by any one monkey.

Input Validation: Do not accept negative numbers for pounds of food eaten.

Code:
#include <iostream>
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;

// Constants.
const int NUM_MONKEYS = 3;
const int NUM_DAYS = 7;

[Code] ....

View 3 Replies View Related

Visual C++ :: Line Graph Using Single Line Values From Bitmap

Feb 3, 2014

I was loaded a bmp file in my mfc window and stored rgb data in a file.My image size is 320x240.

Is possible to pick a single point (location) from that bmp image (Not the whole window)?

i like to plot a line graph using the pointed single line data using the stored file data?

here R is X Axis and G & B is Y Axis.

If i have 2D array of data means how can i plot the line graph?

View 4 Replies View Related

C++ :: Read Unknown Number Of Integer Values And Then Print Count Sum And Average Of Odd Values

Apr 9, 2014

write a c++ program that reads an unknown number of integer values and then print count, sum and average of odd values, even values, positive values, negative values!!

View 1 Replies View Related

C++ :: Write A Program That Replaces Values In A Vector With Their Absolute Values

Dec 4, 2013

This is my code: [tag]

Code:
#include <iostream>
#include <string>
#include <cstring>
#include <vector>

using namespace std;

[Code] .....

View 4 Replies View Related

C :: Save Values From A Char Buffer Into Integer Values Of A Struct?

Jul 3, 2013

I'm attempting to save values from a char buffer into integer values of a struct.

This is what resides in the buffer "STD 2 2 2 2 2 2 2 " and this is my sscanf call

Code:
sscanf(buffer, "STD %d %d %d %d %d %d %d
", &dt_struct.date,
&dt_struct.mth,
&dt_struct.year,
&dt_struct.dow,
&dt_struct.hr,
&dt_struct.min,
&dt_struct.sec);

I then print the values back out in a string using sprintf.

Code:
sprintf(t_string, "STD %d %d %d %d %d %d %d
", dt_struct.date,
dt_struct.mth,
dt_struct.year,
dt_struct.dow,
dt_struct.hr,
dt_struct.min,
dt_struct.sec);

But this is what I get:
STD 0 0 2 0 0 0 2

Instead of what I want:
STD 2 2 2 2 2 2 2

View 7 Replies View Related

C++ :: Dequeuing Integer Values From Heap Results In Garbage Values

Apr 8, 2015

I've been working on a homework assignment that randomly generates integers and populates them into an array (array1). The program is then supposed to:

1.) copy those values to a second empty array (array2)

2.) sort the values already in array1 (using an inline function)

3.) enqueue the unsorted integers from array2 into a heap vector

4.) a third empty array (array3) is supposed to be populated with those unsorted integers (by dequeuing them from the heap), sorted in reverse order.

But no matter what I do, I always get garbage values like these:

I've tried using both a standard random number generator:

array1[i] = rand()%100+1;

And the d_random.h file my instructor gave us, but nothing works.

Here's the code from all 3 files:

HeapTester.cpp

Code:
#include <iostream> // Provides cin, cout
#include <cstdlib> // Provides EXIT_SUCCESS, rand, srand
#include "d_random.h"//Provides random number generator
#include "Heap.h"
using namespace std; // Use C++ Standard namespace
//Elements in each array.
const int arrayLength = 15;//100;

[Code] ....

Why I'm getting those garbage values?

View 6 Replies View Related

C# :: Making String Equal Many Different Values Then Compare Those Values

Dec 18, 2014

I was wondering if this was even possible and if so, how do I do it.

else if (speech.ToLower().Contains("truck") && speech.EndsWith(number))
{
Here I would like to see if my speech had ended with any of the values i would have stored in the string "numbers". If it did, I would like to just take the value and add it to a new string called whatever
}

I have tried this a million different ways and I cant get it to work. I'm not even sure how I would go about storing tons of different numbers in one string, or if that's even possible.

View 10 Replies View Related

C/C++ :: Compare Values Stored In First Array To User Inputted Values In Second Array

Oct 19, 2014

Goal: Write a program that compares the values stored in the first array to the user inputted values in the second array.

In order to fix this error: [URL]...

I had to change my array initialization to one with a star in front of it:

char a1[]={"a","d","b","b","c","b","a","b","c","d","a","c","d","b","d","c","c","a","d","b"};
to:
char *a1[]={"a","d","b","b","c","b","a","b","c","d","a","c","d","b","d","c","c","a","d","b"};

I also changed my 2nd array to one with a star in front of it: char *a2[20];

What does this mean exactly? Putting a star in front of an array?

Also, I am now getting an "unhandled exception" when I try to get input for my 2nd array:

cin>>a2[i];

View 3 Replies View Related

C/C++ :: Display Inputted Values Without Overwriting Other Inputted Values

Jun 16, 2014

How can I display my inputted values here without overwriting the other earlier inputted values. It should be displayed like this [URL].... but mine shows this [URL].... I've been stucked here for hours in thinking for an algorithm. Everything is working fine except the PDISPLAY part

#include<iostream>
#include<iostream>
#include<string>
#include<cctype>
#include<cstdlib>
#include <iomanip>
#include <windows.h>
#include<conio.h>

[Code]...

View 1 Replies View Related







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