Visual C++ :: Display Arrays Using Call Statements
Oct 21, 2014
I am trying to display the following arrays.
int a[4]={5,9,2,10}
int b[3][3]={1,2,3,4,5,6,7,8,9}
int c[2][3][2]={1,2,3,4,5,6,7,8,9,10,11,12}
Using these call statements
Display (a,4);
Display(b,3);
Display(c,2);
I'm not sure on how to put this all together but this is what I have so far.
Code:
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
} int a[4] = {5,9,2,10};
Display(a, 4);
[Code] .....
View 4 Replies
ADVERTISEMENT
Apr 19, 2014
I created class called students which suppose to store students names of in array but when I call the display function it display only the first name. but I want it to display names depending on the array size.
#include <iostream>
#include <sstream>
using namespace std;
const int SIZE=5;
[Code]....
View 3 Replies
View Related
Jun 4, 2014
IF statement. Really new, so this will be simple I'm sure. I'm essentially just trying to roll a 6 and 20 sided die. I want the statement to run "If 20,then display the randomly selected number for 20".
// auto dice roller
#include <iostream>
#include <string>
#include <ctime>
#include <cstdlib>
using namespace std;
const char* twenty[20] = {
"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"
[Code] ......
View 7 Replies
View Related
Apr 19, 2014
I created class called students which suppose to store students names of any sizes in an arrey but when I call the display function it does not show the names.
#include <iostream>
#include <sstream>
using namespace std;
const int SIZE=5;
class students{
public:
string names[SIZE];
[Code] ......
View 1 Replies
View Related
Apr 29, 2013
How to ADD a call to the FindMostExpensive function AFTER the main display loop, and use the index returned to display the information about the most expensive car?
// Session7.cpp : Defines the entry point for the console application.
//using struct
// reading from file
// using functions
#include "stdafx.h"
#include <iostream>
#include <iomanip> // only used to tidy up the console output here
#include <fstream> // added file handling
[Code] .....
View 1 Replies
View Related
Nov 8, 2013
I want to write a code that gets three values from the user and puts them into three arrays. When the user enters -999, I want to print out a chart showing all the values they put in. This is what I have so far but it wont build. It tells me std::string is requested, but I'm not sure where to put it, and printArrays is declared void. How can I fix this?
#include <iostream>
#include <string>
using namespace std;
const int ARSIZE = 400;
void printArrays (string reportTitle, int levelsArray[], int scoresArray[], int starsArray[], int i);
[Code] ....
View 2 Replies
View Related
Aug 17, 2013
I am having a problem with my program to calculate the GPA of a student. The problem that I am having is that I am not able to get my Total Point Value to display the sum of the two arrays. The multiplication for the array is correct and will display correctly, but instead of putting the total into the accumulator it will display the totals in a column. I have tried moving the coding for the calculation out of the loop that converts the letter grade into a point value,and placing it in it's own loop, but I still get the same display output. Below is the code that I have so far. I still have a few elements to add to the code, but they will be easy once I get this display to work right.
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
// Global const
// prototype
int main () {
// Varialbes, Arrays
[Code] ....
View 1 Replies
View Related
Nov 4, 2013
SO Im supposed to write a program that uses arrays to calculate the sum and display it. I keep getting the error that says the sum has to be initialized.
#include <iostream>
using namespace std;
//Function prototype
int sumArray(int);
const int NUM_ELEMENTS = 5;
[Code] .....
View 1 Replies
View Related
Apr 12, 2013
A company uses two text files: one to store employees' details and another to log their sign in/out time.
The details file - called details.txt" has the following format: ID, Name, Date of Birth, SSN, Department, Position - separated by spaces.
An extract from the file looks like this:
10 alice 4/23/1972 123-45-6789 support assistant
3 bob 6/7/1980 111-12-1134 logistics manager
1 carol 10/2/1963 987-123-1143 admin ceo
2 dave 10/3/1974 902-22-8914 admin cfo
17 erin 6/13/1991 126-83-1942 technology supervisor
15 frank 2/22/1987 303-12-1122 logistics assistant
"timelog.txt" contains daily logs of when employees arrive and leave. It has the following format: ID, Date, Arrival Time, Departure Time - separated by spaces. An extract from the file looks like this:
10 2/11 0900 1700
3 2/11 0930 1730
1 2/11 1100 2000
2 2/11 1000 1530
17 2/11 0900 1700
10 2/12 1000 1830
3 2/12 0930 1730
1 2/12 1100 1900
2 2/12 1030 2000
17 2/12 0900 1700
15 2/12 1100 1600
I have to write a program that searches for specific records using some search parameter, and displays them. Ok first i have to read the data from the files and store them. this is what i have so far....
#include <iostream> //Accesses libaries for console input and output
#include <fstream> //Needed to access the fstream object to read files
#include <string> //Needed to access the string class
#include <cstdlib>
[Code] ....
I know my class and array code is totally wrong i dont know how to store the data for the info is in integer and string form... do i use strings, arrays?
View 1 Replies
View Related
Apr 22, 2014
I am writing a class that dynamically allocates an array that holds a user-defined number of test scores (test scores go from 0 to 10 both included). Once all the test scores are entered and validated (values only between 0 and 10, both included), the array should be passed to a function that sorts them in ascending order. Another function should be called that calculates theaverage of all the scores.The main program should display the sorted list of scores and the average of the scores with appropriate headings.
View 6 Replies
View Related
Sep 8, 2014
Write a program to enter data into a table and display on the screen in tabular form. I want to know where are the errors.
#include<iostream>
using namespace std;
int main() {
int table[3][4];
int r,c,i;
r=c=0;
while(r<=2)
[Code] .....
View 3 Replies
View Related
Sep 20, 2012
I have a window I am opening from the parent Dialog by using DoModal:
CMyDlg dml;
dml.DoModal;
When the window opens I want it to run a function on open. Lets just for example say copy files and show a progress bar. Where can I put the function call so that when DoModal is called that function will execute?
View 13 Replies
View Related
Jun 24, 2013
I have MdiForm and Form1 as a child Form1 has a menu 'mnuClear' Sub mnuClear_Click MdiForm a button Clear.
Can you click on the button from MdiForm call sub mnuClear_Click in Form1 Sub mnuClear uses local variables and can not be moved to the module ...
View 1 Replies
View Related
Sep 22, 2012
I'm working with a cross-platform library which defines a function to obtain function addresses from a shared object (i.e. a DLL on Windows). Here's my modified version of the function which works (albeit only on Windows of course):-
Code:
typedef void (*SuilVoidFunc)(void);
/** dlsym wrapper to return a function pointer */
static inline SuilVoidFunc
suil_dlfunc(void* handle, const char* symbol) {
return (SuilVoidFunc)GetProcAddress((HMODULE)handle, symbol);
}
Now, here's the original (cross-platform) version which is giving me a run time error on Windows:-
Code:
typedef void (*SuilVoidFunc)(void);
#define dlsym GetProcAddress
/** dlsym wrapper to return a function pointer */
static inline SuilVoidFunc
suil_dlfunc(void* handle, const char* symbol) {
typedef SuilVoidFunc (*VoidFuncGetter)(void*, const char*);
VoidFuncGetter dlfunc = (VoidFuncGetter)dlsym;
return dlfunc(handle, symbol);
}
That original version fails at the final return line. The error message says "The value of ESP was not properly saved across a function call".
I'm assuming there's a problem with the declaration of VoidFuncGetter (i.e. it'll assume that the caling convention for GetProcAddress() is cdecl when in fact, it's stdcall). What's the most elegant way to fix this and still keep cross-platform compatibility?
View 1 Replies
View Related
Jan 16, 2013
How can I call a dialog , which is present in a seperate Win32 resource DLL .
View 4 Replies
View Related
Dec 23, 2012
I have two problems with the code below:
1. I cannot find a header file to #include that has the sleep function prototype.
2. When I add my own sleep function prototype, I get an unresolved external reference error (for _sleep, not sleep).
What must I #include to get the sleep function prototype? What lib must I include in the linker configuration to resolve the external reference? (I suspect that if I #include the correct header file, the second question might become moot.)
The "man page" at [URL] .... says the header file is <WinBase.h>. But #include'g only <WinBase.h> results in compilation errors.
A response marked "answer" at [URL] ..... says <windows.h> [sic]. #Include'g only <Windows.h> does eliminate the compilation errors.
But apparently that does not bring in the sleep function prototype. Neither does also subsequently #include'g <WinBase.h>. (Which seems to be #include'd by <Windows.h> anyway.)
But even with my own function prototype shown below, I get an unresolved external reference for _sleep. Is that a symptom of my problem: my sleep reference is changed to _sleep? If so, how can avoid that?
According to "man page" (see link above), the external should be resolve in kernel32.lib. And kernel32.lib does appear in the "Additional Dependencies" list under Configuration Properties Linker Input.
Since I am not using C++ features, I tried setting "Compile as C" under Configuration Properties C/C++ Advanced, to no avail.
My code....
#include "stdafx.h"
#include <stdlib.h>
#include <time.h>
#include <Windows.h>
void sleep(DWORD msec); // added later
int _tmain(int argc, char* argv[])
[Code] ....
View 3 Replies
View Related
Jan 19, 2013
Is there some document, that describe the sequence of actions, that result in displaying of a Dialog Window from a .DLL.
One important detail - the Dialog Window is created via resource/toolbox inteface.
Below is code from some example (which works), that displays simple window (with client area inside it).
In this code the window class is ctreated inside of application class.
Here is extract from application class:
Code:
class CMyWindow : public CFrameWnd {
CStatic* cs;
public:
CMyWindow();
};
CMyWindow::CMyWindow() {
Create(NULL, L"MyWindow", WS_VISIBLE, CRect(0,0,200,200));
[code].....
Where is my mistake ?
View 14 Replies
View Related
Jul 14, 2013
I am trying to create a loop to call in the entries from the text file named Set. The entries of Set.txtare :
1 2 3
2 4 5
and so on .. (64 such combinations)[/CODE]
It basically means the first combination for testing is 1 2 3 and next has to be 2 4 5 and so i have 64 such entries defined in set
My test files are located in D://data// and are named tst_data1 to tst_data64.
I created a loop for test set but its incorrect
Code:
// loop for test samples
char basefilename[] = "D://data//";
char , testFilen[160], numiChar[10];
for (int i=1; i<=64; i++) {
strcpy(basefilenme, "D://data//");
strcat(testfilename, Set[]);
[Code] .....
How can i call the Set .txt and how to define it.
View 1 Replies
View Related
Dec 22, 2012
I am making an application that processes multiple files (typically > 500) through a command prompt call. The way I start the command prompt app is by looping using a call to CreateProcess for each file that is to be processed. It works fine, except that I somehow loose 'connection' to my app so that
1: Windows says that the app. is 'Not Responding'
2: The Cprogress bar in my app is not updated before all files have been processed, even though there is a CreateProcess call and a Cprogress.StepIt() from the app for each file that needs processing.
I somehow suspect that the CPU gets swamped... I do not want that Windows starts to say that my app is 'not responding' and I want my Cprogress dialog bar to update according to the number of files that are progressed through.
I wonder if multithreading is the OK way to go instead of just kicking of series of CreateProcess calls? Maybe my CreateProcess is not ending correctly? It seems as if my app is 'not regaining control' before very late. The app never crashes though.
My CreateProcess code is listed below, maybe there can be a problem with it, or maybe I should do things in a different way? My app basicaly works as it never crashes, but with above mentioned problems it is NOT a pro solution...
void CMultiFilerDlg::ProcessFile(CString pdfFile) {
int i=0;
DWORD ProcID;
// Open file in text mode:
STARTUPINFO si;
PROCESS_INFORMATION pi;
char cmdArgs[2052];
[Code] .....
View 6 Replies
View Related
Oct 30, 2013
You need to write a permute class that will take first and second strings to rearrange letters in first, followed by second. For example, if the first is “CAT” string and second is “MAN” string, then the program would print the strings TACMAN, ATCMAN, CTAMAN, TCAMAN, ACTMAN, and CATMAN. The first and second strings can be any length of string or a null.
The permute class uses a Note class as link list note to link all letters arrangement. The permute class has Note pointers, firstNote and lastNote, to point to the beginning and ending Notes of the link list as private data members. There are three other private data members (total, firstString and secondString) to store the total possible number of arrangements and strings pass into the class.
Write a driver to test the permute class to pass in any two strings of any sizes.
Other than mention in the following, you can add more classes, functions, and private data members to this program.
Note class:The Note class needs to have two private data members and a constructor. The two private data members are data and p pointer. The data’s data type is string and p pointer is Note. The Note class constructor has two parameters, one is string and the other is Note pointer.
Permute class:The Permute class has five private data members (*firstNote, *lastNote, total, firstString and secondString). The firstNote and lastNote pointers are point to Note. The total has integer data type. The firstString and secondString have string data type.
There should have at least three public member functions, Permute, permutation and print. The Permute function is the constructor which takes strings to initialize the private data members. The permutation function does the recursive call to arrange the strings and setup the link list. The print function will print out the private data member information.
Driver file:The driver file should declare a Permute eight elements pointer array. Instantiate eight Permute object with the following eight set of data and assign the object to the pointer array. Use a repetition to call the object’s print function to print out the private data member information. If the total of the permute private data member is less than 100 then print out the permutated letters four in a row, otherwise print out 9 in a row.
first = "", second="",
first = "", second ="CATMAN",
first = "C", second ="ATMAN",
first = "CA", second ="TMAN",
first = "CAT", second ="MAN",
first = "CATM", second ="AN",
first = "CATMA", second ="N",
first 1 = "CATMAN", second ="";
View 3 Replies
View Related
Sep 24, 2013
I'm trying to take a value from an edit box and display it in the edit box as hex. I'm using this code:
CString buffer;
int intbuf;
m_edit[5]->GetWindowTextA(buffer);
intbuf = atoi(buffer);
buffer.Format("%02X", intbuf);
m_edit[5]->SetWindowTextA(buffer);
If I include the last line of code here I get a stack overflow error. If I don't include it, I can run through the debugger and the buffer CString is converted to hex just like I want, I just can't display it because I get that error.
View 4 Replies
View Related
Dec 5, 2012
I need to write a function that displays the days of a specified month. I have been looking for sample code but haven't had much luck. Here are the guidelines for the function:
Write a void function named displayCalendarDays. This function is passed two input parameters. The first parameter is an int that represents the start day. Start days are numbered from 0 to 6 with 0 representing Sunday and 6 representing Saturday. The second parameter is an int that represents the number of days in the month. If the start day is not in the range 0 to 6 or if the number of days is not in the range 1 to 31, the program should display useful error message instead of displaying a calendar. If the parameters are OK, the program should display a calendar similar to the following:
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
After the last day of the calendar is displayed, the function should advance the cursor to the next line.
Note that for the display above, the start day is 3 and the numbers of days is 31.
View 1 Replies
View Related
Nov 25, 2012
Used some online code example to put a little project to display raw image. The display does not seem to work.For some purposes, I like this to work with a dialog based MFC project.XDVView is derived from CScrollView.
See OnInitDialog() and OnDraw(CDC* pDC).8bit 768x756
View 14 Replies
View Related
Sep 13, 2013
I haven't seen this before but on Windows 7 Home Professional and VC 2012 in one particular app, a CFileDialog displays only the rightmost 11 characters plus the extension of the default file name. The rest of the name is there and you can scroll left in the file name edit to display it all, but initially the text is shifted left so it doesn't all display.
Code:
CFileDialog dlg(TRUE, "csv", strFileName, OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY, "Comma Seperated Values Files (*.csv)|*.csv|All Files (*.*)|*.*||");
strFileName can contain anything and it will do it. Even a string literal will do it.
View 3 Replies
View Related
Jul 13, 2014
I'm currently making a math program in c++ windows form application. I'm trying to make it so where the user presses the number button I such as 1 button to display a 1 in my textbox.
Code:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
}
View 1 Replies
View Related
Mar 11, 2015
I am having a strange problem trying to display a dialog from a UI thread. The dialog simply fails to display. I have a function DisplayFlashBox(), which creates the UI thread:
CUIThread* CIMUIHelper:: DisplayFlashBox(const CString &sMessage, const int nInstrumentUID) {
CUIThread *pThread = new CUIThread();
pThread->SetString(sMessage);
pThread->SetInstrumentUID(nInstrumentUID);
pThread->CreateThread();
[Code] .....
The dialog doesn't display. When I tried debugging, I found the OnInitDialog() method of CIMFlashBox class doesn't actually return. Very strange. I tried calling the DoModal() method instead of Create, but doesn't display the dialog either.
View 5 Replies
View Related