Visual C++ :: Using If Or Switch With LPCWSTR?
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
ADVERTISEMENT
Apr 13, 2013
#include "stdafx.h"
#include "windows.h"
#include "ddeml.h"
#include "stdio.h"
char szApp[] = "EXCEL";
char szTopic[] = "C:Test.xls";
char szCmd1[] = "[APP.MINIMIZE()]";
[Code] ....
View 2 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
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
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
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
Aug 16, 2014
okay so like case 2 and 3 is not working, also the program is still not finish but why isn't case 2 and 3 not functioning well on the switch part? case 1 works just fine
Code:
#include<stdio.h>
main ()
{
//passcode part (passcode is 1234)
[Code].....
View 5 Replies
View Related
Feb 12, 2015
I have a fundamental question due to my lack of understanding how arrays work.Let say I have a character array (byte array).
1. do array elements have memory adresses? i guess not but ....
2. if yes is it possible to switch two array positions? For examle:
a[x] change with a[y] for x,y < |a|
as oppose to changing values assigned to individual array positions.
View 2 Replies
View Related
Jul 9, 2013
I'm currently doing a project which will trigger an alarm and light up an LED when a character 'E' is detected from a bluetooth input. I'm supposed to program a pic18f4525 board.
I'm having troubles with where to start on the codes to enable the LED to light up upon detection of character 'E'. I'm using ports RD0-RD3. This is how I initialised them in the main loop.
Code:
TRISD = 0b11000000;
PORTD = 0xC0;
Am I doing the initialising right? Also, how to program it to light up when the character's detected?
View 2 Replies
View Related
May 20, 2013
Switch case statements are a substitute for long if statements that compare a variable to several "integral" values ("integral" values are simply values that can be expressed as an integer, such as the value of a char).
So does that mean switch statements can only test if variable == value and nothing more, like > < >= <= != etc... ? I tried to make a program to test this and it seems like switch statements are limited to == but I'm not sure, maybe I'm doing something wrong.
This is the program I tried to make to test this:
Code:
#include <stdio.h>
int main () {
int n;
[Code]....
So is it true that switch statements only work with the built in == operator? if that was the case then I would feel rather meh about switch statements.
View 7 Replies
View Related
Apr 15, 2014
so I am trying to have an switch statement array. but every time i complete a case statement the whole process is returned. the thing is i want the menu to stay up even if i complete the case.
View 2 Replies
View Related
Jan 3, 2014
I'm making a game in OpenGL GLUT. A ball is going to move forwards along the Z axis and hit a wall. I want to be able to move the ball left and right, up and down before firing it off on the Z axis. I'm using glutSpecialKeys for this, and I've got everything set up, but I'm not sure how I use it with a switch statement? Here is a snippet of code:
void Special_Keys (int key, int x, int y){
switch(key){
case GLUT_KEY_UP: //do something
break;
case GLUT_KEY_DOWN: //do something
[Code] .....
Where the comment is saying "do something", I'm not sure what I actually need to do? Is it a method or what?
View 1 Replies
View Related
Aug 8, 2014
The sample output of this program would be:
Please select:
1 - Year
2 - Day
3 - Month
Input choice: 1
Input Number: 2
I'm a Sophomore!
Please select:
1 - Year
2 - Day
3 - Month
Input choice: 2
Input Number: 2
It's Tuesday.
Please select:
1 - Year
2 - Day
3 - Month
Input choice: 3
Input Number: 2
February. Heart's month!
Here is my code, I only typed the Year(levels) yet because when I tried to input 2(day) and 3(month) for the Input choice and after that, Inputting a number to 1-4 would yield the same result to case 1's year levels.
#include <stdio.h>
#include <conio.h>
using namespace std;
[Code].....
how to link the case 2 to days and case 3 to months?
View 1 Replies
View Related
Sep 17, 2014
I have a problem with the switch statement because it doesn't prompt me to input something.
#include <iostream>
#include <fstream>
#include<cstring>
using namespace std;
//Compiler: Dev C++ and cygwin
void rd() {
string txt;
[Code] ....
I want to get rid of this kind of output ...
View 5 Replies
View Related
Oct 8, 2014
if( vehicleUse == 'C' ) // Carpool
{
// TODO: Convert to a switch statement
if( vehicleLoad == 'E' ) // 6-8
cout << "Ford Windstar" << endl;
else if( vehicleLoad == 'F' ) // 8-10
[Code] .....
View 1 Replies
View Related
Sep 23, 2013
is it possible to compare value in switch statement? i.e: a > b
View 5 Replies
View Related
Nov 1, 2013
I am using a switch statement as a menu. If I enter a non-integer value as my choice, I expect the error message , "Invalid entry", to display but instead the output keeps running.
View 2 Replies
View Related
Mar 21, 2014
Right now I have to use seekg to read a letter from a text document then using a switch statement i have to show what that letter is
#include <iostream>
#include <fstream>
#include <math.h>
#include <time.h>
[Code]....
View 7 Replies
View Related
May 1, 2014
I have tried to search all about strings,I have the occurrences and have worked out what letter corresponds with which. I have searched that much i can remove the vowels and reverse my string but I dont know how to swap them. This is what i have this far. When it compiles it just prints the decipher is:
If i even find out am i on the right track ive used caps when swapping to try and stop the doubles over writing,...
#include<stdio.h>
#include<string.h>
int main(void){
int i,count=0;
char secretText[] = "lopsy, hssepokd wl okrhsowk:
[code]....
View 1 Replies
View Related
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
Jan 16, 2014
I was getting errors and I looked into the error and it told me to fix it by adding Code: { } in my case statements. I did, it compiled but fell through the whole thing. Lets say I enter 1, it outputs the was not found 5 times in a row.
Code:
void addressbook::EditNameOrDate() {
std::cout << "Enter 1 to Edit the contacts First Name: " << "
";
std::cout << "Enter 2 to Edit the contacts Last Name: " << "
";
std::cout << "Enter 3 to Edit the contacts Street Address: " << "
[Code] .....
View 8 Replies
View Related
Aug 23, 2013
How to do i fix this code im not good at using function, im trying to pass a statement from switch to my double passengersR i always come out with a error
this output:
Name passenger:
Enter number passenger:
Choose from A to D
if choose A
Total Regular Passenger: 6.19624e-312
did i do something wrong im not really good at function and im trying to learn how to pass switch to void function
Code:
#include<conio.h>
#include <iostream>
#include <Iomanip>
#include <string>
using namespace std;
double passengersR ()
{ double m;
[Code]...
View 4 Replies
View Related
Jun 12, 2013
I pretty much got the assignment done. All it asked for was that you make a C program that displays which manufacturer owned a disk drive based on the code entered. Pretty simple. Just enter 1, 2, 3, or 4 and get the associated manufacturer. Though I am trying to implement an error messege to it for any interger that isn't 1-4.
Code: #include <stdio.h>
int main()
{
[Code]...
o errors are given and it works fine as long as you enter 1-4, but when you enter any other didgit it just stops the program without any messeges.
View 5 Replies
View Related
Jan 31, 2014
Ran into something today that does not make sense:
This compiles: Code: int x = 5;
switch(x) {
case 0:
{
int value = 5;
}
break;
[Code] ....
Ok so it doesn't like int value = 6 b/c of int value = 5 for case 0. However since the value in case 0 is declared within the brackets one would think it has case scope.
So I tried this:
Code: int x = 5;
switch(x) {
case 0:
{
int value = 5;
}
break;
[Code] ....
Now it doesn't like it b/c value has not been declared in case 1:. These two conditions cannot possibly be both true at the same time. You cannot disallow the declaration of value in case 1 b/c it interferes with value in case 0 and at the same time disallow me to use value from case 0 b/c it is not in scope. If it was not in scope then theoretically I should be able to declare value in case 1.
Both MSVS 2012 and 2013 exhibit the same behavior. I checked the standard and it is unclear on the matter.
View 7 Replies
View Related