Visual C++ :: File Processing Within A Switch?
Nov 17, 2014
The error ive been getting with this code is after i go to the check out option, enter the data then click (ctrl + z). Then program glitches back and forth from the menu to the check out option continuously and im not entirely sure why.
Heres my code:
Code:
#include <iostream>
#include <windows.h>
#include <iomanip>
#include <fstream>
using namespace std;
void checkOut(){
cout << setw(10) << "Ministry of Health Hospital System
[code]....
View 7 Replies
ADVERTISEMENT
Nov 16, 2014
The error ive been getting with this code is after i go to the check out option, enter the data then click (ctrl + z). Then program glitches back and forth from the menu to the check out option continuously and im not entirely sure why.
Heres my code:
[#include <iostream>
#include <windows.h>
#include <iomanip>
#include <fstream>
using namespace std;
void records(){
cout << setw(10) << "Ministry of Health Hospital System
[code].....
View 1 Replies
View Related
Jul 23, 2014
Is there a way I can do message processing between a Win32 application and Javascript using some Windows CallBack function or using Send or Post message?
View 6 Replies
View Related
Mar 12, 2013
In my project I'm using PVOID pointer to store real time data. After getting this data I will convert the data into byte array, like below
Code:
byte *bPoint = NULL;
PVOID pvData;
byte TempArr[1024];
bPoint = (byte*) pvData;
for(int i=0;i<1024;i++)
TempArr[i] = (byte) (*bPoint + i);
Processing time for the above code takes 9500 to 9900 microseconds (Used QueryPerformanceCounter).
Code:
TempArr[0] = ((BYTE*) pvData) [0];
This code takes 1100 to 1200 microseconds. My doubt is, The processing time of PVOID data into byte array conversion takes time like above? Or any other easy way(PVOID data into byte array conversion) to reduce the processing time?
View 14 Replies
View Related
Aug 6, 2013
This code does what it is supposed to do, but at the end of the file, I get an error that I have never encountered before. What exactly is stack smashing? I suspect that the files and the permissions might be the issue.
Code:
/*Write a a program for file matching
*/
#include<stdio.h>
#include<stdlib.h>
int main(void)
}
[code].....
View 8 Replies
View Related
May 2, 2015
While running a Doc/View SDI, is there any way to switch from text mode to rtf mode during runtime? Search reveals nothing.
Say I have an editor and I want the app to use text, I can set the ctor as follows.
Code:
CEditorDoc::CEditorDoc() {
// TODO: add one-time construction code here
m_bRTF = FALSE;
}
But once I've done that and compiled the app, while it's running, is there a way for the user (or programmer) to change the mode back to RTF? One solution that occurred to me is to use 2 document classes, but that's a hassle.
View 8 Replies
View Related
Oct 9, 2013
i am trying to read an ini file and usse an if or switch to take action.
i have this in ini.h file
LPCWSTR ini_read_string(LPCWSTR _ini_File_Name, LPCWSTR _ini_Section_Name, LPCWSTR _ini_Key_Name, LPCWSTR _ini_Default )
{
TCHAR _Rvalue[5];
GetPrivateProfileStringW(_ini_Section_Name,_ini_Key_Name,_ini_Default,_Rvalue,5,_ini_File_Name);
return (LPCWSTR) _Rvalue;
}
now when i do this:
OverLay[0]=ini_read_string(map_file_ini,_T("Section"),_T("Key"),_T("NULL"));
if(OverLay[0]==_T("NULL"))MessageBox(NULL,_T("File or kay not exists"),_T("Error"),MB_ICONEXCLAMATION|MB_OK);
but the key dos not exists, so it will return NULL, but yet i am not getting the message box (LPCWSTR) i also dit try
if(OverLay[0]=="NULL"), if(OverLay[0]==L"NULL"),if(OverLay[0]== (LPCWSTR)"NULL"), if(OverLay[0]== (LPCWSTR)L"NULL"), if(OverLay[0]== (LPCWSTR)_T("NULL"))
but it never dit work.to be sure of the returning value i also dit this
MessageBox(NULL,ini_read_string(map_file_ini,_T("Section"),_T("kay"),_T("NULL")),(LPCWSTR)L"Error!",MB_ICONEXCLAMATION|MB_OK);
and ther it is, an message box with the text "NULL" so why is the if(OverLay[0]==xxx) not working? and i also need a big list so an working switch(OverLay[0]) will be nice as well (else i need to do if/ else if many times)
View 14 Replies
View Related
Jan 16, 2014
Essentially I have an MDI that I want to be able to switch between having all my views tabbed when one is maximized and having all my views cascaded or tiled to their previous sizes. The MFC app wizard provides options for either tabbed or untabbed views.
How to implement this? What is the class that MFC uses to place each of the MDI child frames in tabs?
View 1 Replies
View Related
Dec 30, 2014
I am trying to make a program which manages the data of 5 different patients (its an uni assignment), and i want to use a switch case as a menu to switch between the patients. All other functions (as for example putting the infromation on a file) work, but i cant figure out to bring the switch to work. First it asks for the number of the patient which should be worked with, this works perfectly, but afterwards changiung between the persons doesnt work as thought. It should ask everytime after it switches to one patient (i removed some functions to make it easier to read) and then asks to which it should jump next. If i put the number of one case (lets say 3) it just stops the program.
********Example:
user@pc ~/wherever $ ./program
current variables:
jo = 2
a = 0
1 //the entered number
The variable a = 1
patient 1
Enter the number of the next patient2
// and then it closes
**************
The same thing happens if i compile an example code from a book, it writes the first case and then stops.
I looked already through the forum but didnt find a person with a similar problem, maybe i didnt dig deep enough.
I am running Linux Mint 17 and use gcc as compiler.
Code:
include <stdio.h>
#include <stdlib.h>
int a=0;
int jo=2;
int main(void){
printf("current variables:
jo = %d
a = %d
[Code]...
View 13 Replies
View Related
Mar 18, 2013
i cant display the data written to this file in a switch statement (case 2) what am i doing wrong..the file data is being written into the text file but i cant display it
insert
Code:
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
FILE *fp; //creates a file pointer
typedef struct date_info
[Code].....
View 8 Replies
View Related
Apr 28, 2013
I need to set a timer but still have the program processing info. I have looked into using sleep but when using this all processing stops to my knowledge. I tried to use the settimer method but was having some issues since I am not using a dialog based interface.
View 1 Replies
View Related
Feb 10, 2014
[URL] ....
typedef double (*Matrix)[imax][jmax];
Matrix xboundary(){
Matrix xx;
double x[imax][jmax];
int i;
[Code] .....
All I want to do is be able to Return "x" in some way.
View 1 Replies
View Related
Jun 22, 2013
I've been coding for about 10 years now and it just got to my mind that I would like to learn about how I can create speech recognition software. I am mostly interested in doing this from ground 0 not because there are no other libs I can use, but it's more of an interest to me.
grasp this new and magnificent feature that's becoming more and more used nowadays.
My preference would be coding in C++ (more because of OOP that's why not C) and I don't really like Java.
I know what I'm getting involved in but I am thrilled and willing to go all the way to achieve my goal.
View 4 Replies
View Related
Jun 13, 2014
I have a problem with calculating the CPUtime. I am using CPLEX to solve linear programming with 3 diferent algorithms.
1-primal Simplex
2-Dual Simplex
3-Barrier Method.
When I am trying to use Barrier method, my clock does not give me a right processing time. I don't have any problem with the other two methods. The value I am getting from ticks2 is 0 when I am using Barrier solver unlike the two other methods that I am getting some small values (ticks1 is fine). Using time_t ticks1 , ticks2 and time(&ticks1) and finally difftime(ticks1,ticks2) also gives me an integer number which is not precise enough. I need a way to compute cputime with accuracy of at least 2 decimals.
clock_t ticks1,ticks2;
double solvingtime
if (solver.primopt==1){
ticks1=clock();
status=CPXprimopt(myEnv, myLP);
ticks2=clock();
[code]....
View 1 Replies
View Related
Oct 7, 2014
I am developing a small game using MFC in which the game options like new game, save, open, exit etc. can be selected from the menu as well as from the buttons inside the window. I have no problems with the menu but the buttons do not seem to work at all.
The buttons are created at runtime using CButton class. To associate the buttons with the corresponding functions, I just used the same resource ID for the buttons as the menu options, but that did not work. When I click on the buttons, nothing happens. If I assign different resource IDs to the buttons, how do I handle the message map entries? Do I have to write different message map entries for the menus and the buttons while their function is exactly the same?
View 6 Replies
View Related
Jun 16, 2013
Is there a program that can remove the functions in a program by preprocessing
Code:
#include<stdio.h>
int is_even(int number);
int main(void)
{
if(is_even(number))
{
printf("%d is even", number);
}
}
[Code]...
To something like
Code:
#include<stdio.h>
int is_even(int number);
int main(void)
{
if( number%2 ==0 )
{
printf("%d is even", number);
}
}
I use the "-E" option when compiling with gcc on linux but its output still contains funcitons. Is there a preprocessing program that can remove functions from a program?
View 6 Replies
View Related
Nov 26, 2013
It's not something trivial but I would like to know the best way to process multiple outputs, for example:
Input
First line of input will contain a number T = number of test cases. Following lines will contain a string each.
Output
For each string, print on a single line, "UNIQUE" - if the characters are all unique, else print "NOT UNIQUE"
Sample Input
3
DELHI
london
#include<iostream>
Sample Output
UNIQUE
NOT UNIQUE
NOT UNIQUE
So how can I accomplish outputs like that? My code so far is:
Code:
int main(int argc, char *argv[]) {
int inputs, count=0;
char str[100];
char *ptr;
scanf("%d",&inputs);
[Code] ....
But the above will obviously print the output after each input, so I want to know how can I achieve the result given in the problem. Also another thing I want to know is, I am using an array of 100 char, which it can hold a string up to 100 characters, but what do I have to do if I want to handle string with no limit? Just declaring char *str is no good, so what to do?
View 5 Replies
View Related
Feb 5, 2013
I want to calculate processing time in milliseconds as most of function I found give me in second. I am new user to C++, the code will be running under linux.
View 5 Replies
View Related
Apr 22, 2013
I working on an assignment that processes an array of structs. In the main function I am attempting to declare an array of Author structures with 3 elements. It is supposed to be initialized to set all of the string fields (the names and book titles) to "NONE", and the double fields (the prices) to zero. This is supposed to be done in one statement, not using loops. Here is what I have.
struct BookInfo struct Author
{ {
string title; string authorName;
double price; BookInfo books[SIZE] //SIZE = 3
}; };
//prototype for function to print the content of array on screen
void showInfo(Author a[], int size);
[Code] .....
I was under the impression that an array can only hold the values of one data type. So doubles and strings in the same array doesn't make sense to me. However, that's the example my teacher drew up. The error keeps telling me that there are too many initializer values.
View 4 Replies
View Related
Feb 20, 2014
I'm trying to find the fastest method to find whether or not two rectangles intersect in an effort to streamline my code. I've built this function into a rectangle class I created below.
struct rectangle{
rectangle() :X1(0), Y1(0), X2(0), Y2(0) {};
rectangle(int X1, int Y1, int X2, int Y2)
:X1(X1), Y1(Y1), X2(X2), Y2(Y2) {};
[Code].....
View 3 Replies
View Related
Feb 21, 2012
I've tried to form together the following code so that I can process multiple files from one user specified directory. However, when I run the program it works great for the first file, but all other files are blank. The problem starts on the following line:
while(FileIn.good())
//---------------------------------------------------
#include <fstream>
#include <iostream>
#include <dirent.h>
#include <sys/stat.h>
using namespace std;
struct dirent *dirp;
[code]....
View 14 Replies
View Related
Jul 5, 2012
I am reading in some large files to process. The files need to be parsed into multi-line sub units for processing (by a different physical process). My current setup is crude and parses the entire file into memory before beginning to process the sub units. This is fine as long as the file fits, so I get into trouble > 2GB or so when my machine flat runs out of memory. The simple thing to do is to only read in some of the file, process what was read in, and then read in more. I more or less know how to stop reading at some point in the file, but I'm not sure how to resume from that point later when I need more data. Is there a way to count lines and then getline() starting from a specific point in the file? From reading the getline() doc, it doesn't look like there is.
This is my current function,
Code:
void ParseFile(char *path, char type) {
// open input file
ifstream input_file(path);
if( !input_file.good() ) { cerr << "Failed to open " << path << endl; exit(ERRCODE_ERROR); }
int pos = 1;
[Code] ....
I need to remove the code to open the file from this function and open it elsewhere. I would like to call this every time I run out of data, if( tasks.empty() ), and get more data from the input file, but I don't know how to resume reading the input file from where I left off.
If this is not possible, I guess I would have to place a function call in while( input_file.good() ) to call out and process the data I have. When the current tasks list is finished, the list could be cleared and control returned into the while loop to continue reading input and start re-populating the list.
View 2 Replies
View Related
Feb 1, 2013
where to start and how it should be structured. how I should go about writing this program, like should i make functions, pointers, etc. And to display the menu, is it easiest to just use printf statements or is there something more efficient.
View 3 Replies
View Related
Apr 12, 2013
I'm very new to MFC & VisualC++. I'm using MSVS2010 Pro. I am trying to write/debug a simple form that saves and restores the content of some edit controls. It seems to work as expected, except the file saves only to the Project Folder, regardless of where I browse and select to save the file.
Code:
void CMFC_FileDialogDlg::OnBnClickedbtnsave() {
this->UpdateData();
CFile f;
//Kinda Correct, Works but still saves in Project Folder
BOOL b_OpenFileDialog = FALSE;//this doesn't act as bool in CFileDialog?
[Code] ....
My only experience is a little simple VB programming in Excel, so any specific examples??? Also, rules seem to change from version to version? I have to "update" a number of undocumented programs.
View 4 Replies
View Related
Oct 11, 2013
How to use string and if or switch together
I want to make something like some users using the same machine so they need to be registered to the system and the their id something like this (H510698541) and their information should appear on the screen.
View 2 Replies
View Related
Mar 6, 2013
I was wondering how you would put this if else statement to a switch statement.
void PlayerDB::AddPlayer(const Player& avatarPlayer) {
char * playerName = new char[avatarPlayer.lenName()];
Player*player = NULL;
[Code] ....
View 1 Replies
View Related