Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all 3021 articles
Browse latest View live

[RESOLVED] Error while statically linking Libsodium

$
0
0
It appears that I'm linking libsodium correctly, but I'm getting linker errors for _sodium_init, I'm using Visual Studio 2015, and the libsodium.lib (prebuilt) for msvc 140 (for vs2015). The project is c++. This is how my setting look for linker: http://prntscr.com/ixv042 For additional includes, my settings look like this: http://prntscr.com/ixv0mg The folder that the project resides in looks like this: http://prntscr.com/ixv0vw I'm including sodium.h as so: http://prntscr.com/ixv1go and of course, in main() I'm doing Code: --------- sodium_init() --------- I'm not sure why I would be getting linker errors, does anyone spot anything wrong with the code?

Some techniques in C++

$
0
0
in this piece of code bit masking technique and XOR operation are used, could you please explain me about these techniques and what's the alternative ways instead of these methods? Code: --------- for (i = 1; i <= n; i++) { if (i == pow(2, p)) { Final[i] = 0; p++; } else { Final[i] = b[j]; j++; } } if ((i&j) == i) Final[i] ^= Final[j]; --------- and in the following code also bit masking technique is used, and why 2 for loop is used here? whats the meaning of this lines: Code: --------- for (i = 1; i < pow(2, r); i = pow(2, x)) { for (j = 1; j <= n; j++) { if ((i&j) == i) Final[i] ^= Final[j]; } x++; std::cout << std::endl << i <<" " <

Important question

$
0
0
Hello I have written a code like the following: in this code, I have 2 matrixes called check which is like(with 3 rows and 7 columns): Code: --------- 0 0 0 1 1 1 1 0 1 1 0 0 1 1 1 0 1 0 1 0 1 --------- also, I have another matrix called decodedBits[b] which is a matrix with one row and 7 columns contain just binary numbers(I wrote other code in another part which calculate decodedBits[b]). and the main part of this code corresponds to syndrome[a] which is equal to the multiplication of check matrix and decodedBits so: syndrome[a]= check[a][b] * decodedBits[b] and the result will be a vector contains one row and 3 columns like: [- - -] until this step, everything must be fixed and I cannot change them because they are roles. then I used else if statements in my code which affected by the result of syndrome calculation above, here if the result is [0 0 0] or zero vector, there is no error occurred, otherwise if : [0 0 1] then the first bit of vector decodedBits has an error [0 1 0]then the second bit of vector decodedBits has an error [0 1 1]then the 3rd bit of vector decodedBits has an error [1 0 0]then the 4th bit of vector decodedBits has an error [1 0 1]then the 5th bit of vector decodedBits has an error [1 1 0]then the 6th bit of vector decodedBits has an error [1 1 1]then the 7th bit of vector decodedBits has an error in my code, I implemented above strategy, but when I want to extend my check matrix like the following: Code: --------- 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 --------- Code: --------- 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 --------- and etc... so for sure the vector decodedBits will also extend according to the columns of proper checkMatrix above, but for calculating syndrome part I cannot use my way (in my code)and its so difficult and time consuming if I want to write if else for all cases, so now I'm looking for a method which supports all dimension when I want to extend these matrixes in other classes: my code: Code: --------- void D(std::vector &codedVector, std::vector &decodedVector) { int decodedBits[7]; for (int bits = 0; bits < 7; bits++) { if (codedVector[bits] < (voltage / 4)) { decodedBits[bits] = 0; } else { decodedBits[bits] = 1; } } char syndrome[3]; for (int a = 0; a < 3; a++) { char result = 0; for (int b = 0; b < 7; b++) { result += (check[a][b] * decodedBits[b]); } syndrome[a] = result % 2; } if ((syndrome[2] != 0) || (syndrome[1] != 0) || (syndrome[0] != 0)) { //The syndrome indicates where the error is if ((syndrome[0] == 0) && (syndrome[1] == 0) && (syndrome[2] == 1)) { decodedBits[0] ^= 1; } else if ((syndrome[0] == 0) && (syndrome[1] == 1) && (syndrome[2] == 0)) { decodedBits[1] ^= 1; } else if ((syndrome[0] == 0) && (syndrome[1] == 1) && (syndrome[2] == 1)) { decodedBits[2] ^= 1; } else if ((syndrome[0] == 1) && (syndrome[1] == 0) && (syndrome[2] == 0)) { decodedBits[3] ^= 1; } else if ((syndrome[0] == 1) && (syndrome[1] == 0) && (syndrome[2] == 1)) { decodedBits[4] ^= 1; } else if ((syndrome[0] == 1) && (syndrome[1] == 1) && (syndrome[2] == 0)) { decodedBits[5] ^= 1; } else { decodedBits[6] ^= 1; } } ---------

Create a new stack in which to put every third element of the first stack

$
0
0
Hello! I need some help. I have to do the following task: Create a stack with numbers in the range from -50 to +50. After creating the stack, perform the following actions: create a new stack, in which every third element of the first stack will be placed. Upon completion, all stacks must be removed. I was able to write the code of the program with creating a stack in the specified range, viewing and deleting it, but I can not implement the function to create the second stack. Code: --------- #include "stdafx.h" #include #include #include #include using namespace std; struct Stack { int info; int in; Stack *next; } *begin1, *second; Stack* InStack(Stack*, int); void View(Stack*); Stack* DelStackAll(Stack*); int main() { srand(time(0)); int i; for(i=1; i<=10; i++) { begin1=InStack(begin1, rand()%101-50); } View(begin1); begin1=DelStackAll(begin1); getchar(); } Stack* InStack(Stack *p, int in){ Stack *t=new Stack; t->info=in; t->next=p; return t; } void View(Stack *p) { Stack *t=p; while (t!=NULL) { cout<info; t=t->next; } cout<next; delete t; } return p; } --------- I will be very grateful for the help!

"Cannot Open Source File" that is definitely there

$
0
0
I'm going up the wall with this one. I'm trying to include a certain library, but VS2017 insists it can't find the header file. It's been a long time since I've used Visual Studio or C++, but I was able to include another library by following these same steps, so I feel silly that I can't do it again! For context's sake, I'm trying to work with the DragonBones/SFML library (https://github.com/DragonBones/DragonBonesCPP/tree/master/SFML). The header file is "DragonBonesHeaders.h," and is included in a folder called "dragonBones" by default. The include statements reference it by its subfolder, #include . First, I set up the project with an Additional Include Directory to the DragonBones include directory, using a relative path. Failure. I try an absolute path - zilch. Then, I get annoyed at how many folders the snapshot dubbed "dragonBones" by default (four and a half), so I start renaming folders just to make sure the identical names aren't causing the problem. The include statements now read: #include . Nothing. Then, I tried to get rid of the subfolder problem entirely by adding dragonBonesCore to my Additional Include Directories and changing the include statements to #include . Nope! This is getting so silly that I don't even know if I can trust copy and paste. Here are some screenshots instead, so you can see the exact content. Additional Include Directories for the project in question: Image: https://i.imgur.com/sYTUIUy.png The folder containing the file, with its directory structure visible: Image: https://i.imgur.com/uvxfVSW.png The original #include statement, using my renamed folder: Image: https://i.imgur.com/JJ4yDUG.png The errors: Image: https://i.imgur.com/KyLKJxm.png The modified #include statement, linking directly to the containing folder: Image: https://i.imgur.com/q40YSko.png The error: Image: https://i.imgur.com/utxILuO.png

[RESOLVED] "Cannot Open Source File" that is definitely there

$
0
0
I'm going up the wall with this one. I'm trying to include a certain library, but VS2017 insists it can't find the header file. It's been a long time since I've used Visual Studio or C++, but I was able to include another library by following these same steps, so I feel silly that I can't do it again! For context's sake, I'm trying to work with the DragonBones/SFML library (https://github.com/DragonBones/DragonBonesCPP/tree/master/SFML). The header file is "DragonBonesHeaders.h," and is included in a folder called "dragonBones" by default. The include statements reference it by its subfolder, #include . First, I set up the project with an Additional Include Directory to the DragonBones include directory, using a relative path. Failure. I try an absolute path - zilch. Then, I get annoyed at how many folders the snapshot dubbed "dragonBones" by default (four and a half), so I start renaming folders just to make sure the identical names aren't causing the problem. The include statements now read: #include . Nothing. Then, I tried to get rid of the subfolder problem entirely by adding dragonBonesCore to my Additional Include Directories and changing the include statements to #include . Nope! This is getting so silly that I don't even know if I can trust copy and paste. Here are some screenshots instead, so you can see the exact content. Additional Include Directories for the project in question: Image: https://i.imgur.com/sYTUIUy.png The folder containing the file, with its directory structure visible: Image: https://i.imgur.com/uvxfVSW.png The original #include statement, using my renamed folder: Image: https://i.imgur.com/JJ4yDUG.png The errors: Image: https://i.imgur.com/KyLKJxm.png The modified #include statement, linking directly to the containing folder: Image: https://i.imgur.com/q40YSko.png The error: Image: https://i.imgur.com/utxILuO.png

HTCvive VR Controller Information C++

$
0
0
Hi, I need to get three informations for each HTCvive controller: Battery status, Is it connected to the steam vr Is it's charging (like is it ) But, i dont have any idea how to do that using c++. Anyone know how to do it? Its hard stuff to find through the internet. Iv try to get variable from steam vr memory, but i can't get static variable. Its the bad idea anyway.

Delete all elements that are less than the average value of queue

$
0
0
Hello! I need some help. I must do the following task: create a one-way queue with numbers in the range from -50 to +50. After creating the queue, perform the following: find the average value of all queue elements and delete all elements that are less than the average value. At the end of the job, all queues must be deleted. I was able to write code to create a queue, delete it, and find the average value of all the elements. However, I can not implement the function of removing elements in the queue that are less than average. Please help me write this function to remove elements that are less then average value of all the elements of the queue, I will be very grateful for your help! Code: --------- #include "stdafx.h" #include #include using namespace std; struct queue{ int info; queue *next; }*b, *e; void AddQueue (queue **b, queue **e, int in) { queue *t=new queue; t->info=in; t->next=NULL; if (*b==NULL) *b=*e=t; else { (*e)->next=t; *e=t; } return; } queue *ReadQueue(queue *t, int &in) { if (t==NULL) { cout<<"Queue is empty!\n"; return NULL; } while (t!=NULL) { in=t->info; cout<next; } cout<info; p=p->next; } aver=(double)sum/number; cout<<"Average value= "<next; delete t; } *e=NULL; } int _tmain(int argc, _TCHAR* argv[]) { b=e=NULL; queue *t=NULL; int inf, n; double sum; cout<<"Input the number of elements"<>n; for(int i=0; i

[RESOLVED] VMI Provider convert out parameters

$
0
0
Hi, I need to use some methods of the WMI Provider but, one method has a non stardard out parameter. I am try to convert the out parameters of the function "IWbemServices::ExecMethod", the returned variable "pOutParams" has a CIMTYPE = CIM-ARRAY-OBJECT (8205). If i use the function "IWbemClassObject::GetObjectText" I receive the following value: [abstract] class __PARAMETERS { [Out, EmbeddedInstance("UWF_ExcludedFile"): ToSubClass, ID(0): DisableOverride ToInstance] UWF_ExcludedFile ExcludedFiles[] = { instance of UWF_ExcludedFile { FileName = "\\MyFolder"; }}; [out] uint32 ReturnValue = 0; }; following I post a code snippet: Code: --------- // set up to call the Win32_Process::Create method IEnumWbemClassObject *pEnum = NULL; BSTR ObjectName = SysAllocString(L"GetExclusions"); BSTR ClassName = SysAllocString(L"UWF_Volume"); BSTR bstrQuery = SysAllocString(L"Select * from UWF_Volume"); hres = pSvc->ExecQuery(_bstr_t(L"WQL"), //Query Language bstrQuery, //Query to Execute WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, //Make a semi-synchronous call NULL, //Context &pEnum /*Enumeration Interface*/); hres = WBEM_S_NO_ERROR; ULONG ulReturned; IWbemClassObject *pObj; DWORD retVal = 0; //Get the Next Object from the collection hres = pEnum->Next(WBEM_INFINITE, //Timeout 1, //No of objects requested &pObj, //Returned Object &ulReturned /*No of object returned*/); IWbemClassObject* pClass = NULL; hres = pSvc->GetObject(ClassName, 0, NULL, &pClass, NULL); IWbemClassObject* pInParamsDefinition = NULL; IWbemClassObject* pOutParamsDefinition = NULL; hres = pClass->GetMethod(ObjectName, 0, &pInParamsDefinition, &pOutParamsDefinition); VARIANT pathVariable; VariantInit(&pathVariable); hres = pObj->Get(_bstr_t(L"__PATH"), 0, &pathVariable, NULL, NULL); printf("\npObj Get returned 0x%x:", hres); IWbemClassObject* pOutParams = NULL; if (callType == EXEC_METHOD) { // Execute Method hres = pSvc->ExecMethod(pathVariable.bstrVal, ObjectName, 0, NULL, NULL, &pOutParams, NULL); VARIANT varReturnValue; hres = pOutParams->Get(_bstr_t(L"ReturnValue"), 0, &varReturnValue, NULL, 0); CIMTYPE pType; VARIANT value; hres = pOutParams->Get(_bstr_t(L"ExcludedFiles"), 0, &value, &pType, 0); ;Value has the CIMTYPE = CIM-ARRAY-OBJECT --------- Do You know what do i need to convert this data?

Token pasting

$
0
0
Suppose I want to call a function based on the value of some variable - e.g. Code: --------- if (some_var == 1) { helper1_func (); } else if (some_var == 2) { helper2_func (); } --------- Obviously that's quite simple but if *some_var *can have 20 different values it'd soon start to get pretty convoluted. Is there a cleverer way to do this (e.g. with token pasting or something like that?)

Noob question: Copied functions to header file, now tons of errors

$
0
0
Hello, Im a n00b with c++ and was building my entire program in the main.cpp, including all function defenitions. This gave troubles though, because i couldnt call functions from functions that were declared below that line. Eg: Code: --------- string dosomething() { dothis(); // errors because dothis isnt declared yet } void dothis() { //do stuff } --------- I tried to fix this by copying all my functions / includes / variable declarations to a header file, and include that in my .cpp file, but now i have hundreds of strange errors, like: string not declared, all the function names are suddenly unindentified What did i do wrong? Its probably some really big n00b mistake, but still

return value in class method

$
0
0
In this code: Code: --------- const int SIZE = 1024; // numero di byte che possono essere memorizzati in ciascun settore class Disco { unsigned int* _vett; // vettore di settori int _quantiSettori; // numero di settori nel Disco int _quantiLiberi; // numero di settori attualmente liberi int _quantiFile; // numero di file memorizzati fino ad ora static int _quantiDischi; // numero di Dischi presenti in memoria // mascheramento costruttore di copia e dell'op. di assegnamento Disco(const Disco&); Disco& operator=(const Disco&); public: // --- PRIMA PARTE --- Disco(int); int riserva(int); friend ostream& operator<< (ostream&, const Disco&); Disco& cancella(int); // --- SECONDA PARTE --- Disco& operator!(); void deframmenta(); static int getQuantiDischi(){ return Disco::_quantiDischi; }; ~Disco(){ delete[] _vett; Disco::_quantiDischi--;}; }; --------- Code: --------- int Disco::_quantiDischi = 0; // inizializzazione della variabile statica 'quantiDischi' // --- PRIMA PARTE --- Disco::Disco(int set){ if ( set <= 0 ) set = 10; _quantiSettori = set; _vett = new unsigned int[_quantiSettori]; for (int i = 0; i < _quantiSettori; i++) _vett[i] = 0; _quantiFile = 0; _quantiLiberi = _quantiSettori; Disco::_quantiDischi++; } int Disco::riserva(int dim) { int quantiNecessari = (dim / SIZE); // calcolo il numero di settori necessari if (quantiNecessari*SIZE < dim) quantiNecessari++; if (quantiNecessari > _quantiLiberi) // non ci sono settori sufficienti da riservare al file return 0; _quantiLiberi -= quantiNecessari; _quantiFile++; for (int i = 0, k=0; i < _quantiSettori && k < quantiNecessari; i++) if (_vett[i] == 0){ _vett[i] = _quantiFile; k++; } return _quantiFile; } Disco& Disco::cancella(int id) { for (int i = 0; i < _quantiSettori; i++) if (_vett[i] == id){ _vett[i] = 0; _quantiLiberi++; } return *this; } ostream& operator<<(ostream& os, const Disco&d){ for (int i = 0; i < d._quantiSettori; i++) os << d._vett[i]; os << endl; return os; } // --- SECONDA PARTE --- void Disco::deframmenta(){ // bubble sort for (int i = 0; i < _quantiSettori - 1; i++){ bool flag = true; for (int j = _quantiSettori - 1; j > i; j--){ if ( _vett[j - 1] < _vett[j] ){ flag = false; int aux = _vett[j]; _vett[j] = _vett[j - 1]; _vett[j-1] = aux; } } if (flag) break; } } Disco& Disco::operator!(){ for (int i = 0; i < _quantiSettori; i++) _vett[i] = 0; _quantiFile = 0; _quantiLiberi = _quantiSettori; return *this; } --------- Can I define Disco& cancella(int) without return value? What is the advantage to define Disco& as return value?! Thanks *void cancella(int)* Code: --------- void Disco::cancella(int id) { for (int i = 0; i < _quantiSettori; i++) if (_vett[i] == id){ _vett[i] = 0; _quantiLiberi++; } } --------- The same thing for *operator!*, can i define it in this way? Code: --------- void Disco::operator!(){ for (int i = 0; i < _quantiSettori; i++) _vett[i] = 0; _quantiFile = 0; _quantiLiberi = _quantiSettori; } ---------

Meson and Visual Studio

$
0
0
Is anyone here using Meson in conjunction with MSVC? I'm just trying to get to grips with it by building a Gnome open source library called Glib. I've figured out that I need to open a VS Command Prompt and type *meson --backend=vs*. This does produce some vcxproj files for me - but they only contain 32-bit targets. I asked about this on the Glib forum and I was told that I need to create different VS Command Prompts (i.e. my existing one, plus a new one for building 64-bit targets). AFAICT my existing Command Prompt runs a batch file called *VsDevCmd.bat*. Looking at it in a text editor I can see various references to x86 and x32 - but no references to x64 (even though I'm running on a 64-bit OS). I'm working with VS2015 Community Edition and I've built 64-bit apps with it previously (so I do know it's 64-bit capable). But how do I create a "64-bit aware" version of the VS Command Prompt? (I must admit, it's kinda sounding like nonsense to me... :confused: )

[RESOLVED] String concatenation

$
0
0
I'm building a project which uses stuff like this:- Code: --------- #define MXFPRIu08 "u" // whatever... fprintf(f, "%03"MXFPRIu08, i); --------- I'm guessing the above should get converted to *fprintf(f, "%03u", i);* but instead, the compiler is giving me:- Code: --------- error C3688: invalid literal suffix 'MXFPRIu08'; literal operator or literal operator template 'operator ""MXFPRIu08' not found --------- This code has been written by someone who I know to be a competent programmer so I assume there must be something wrong at my end. Do I need to set something up to make this work?

MSB4018 - does the linker have an equivalent of STRICT ?

$
0
0
I'm building a library called AAF. I built it once with VS2005 and didn't have any problems but when I try to build with VS2015, the Release versions gives me these errors at the linker stage:- Code: --------- error MSB4018: The "Link" task failed unexpectedly. 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(638,5): error MSB4018: System.NullReferenceException: Object reference not set to an instance of an object. 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(638,5): error MSB4018: at Microsoft.Build.CPPTasks.Link.ForcedRebuildRequired() 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(638,5): error MSB4018: at Microsoft.Build.CPPTasks.TrackedVCToolTask.ComputeOutOfDateSources() 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(638,5): error MSB4018: at Microsoft.Build.CPPTasks.TrackedVCToolTask.SkipTaskExecution() 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(638,5): error MSB4018: at Microsoft.Build.Utilities.ToolTask.Execute() 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(638,5): error MSB4018: at Microsoft.Build.CPPTasks.TrackedVCToolTask.Execute() 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(638,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(638,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() --------- I did some research and discovered that this can be caused by the linker not being able to create a target folder for the output files. However, that doesn't seem to be the case here. For both 32-bit and 64-bit the Debug versions both compile and link fine - but both Release builds fail. I just wondered if some warning is getting treated as an error somehow? (although I don't actually see any warnings when building the Debug builds... :( )

My first program 😀

$
0
0
Hey, I'm a beginner in coding and this is my first C++ program, so I just wanted know if all was okay :wave: Code: --------- #include using namespace std; #include #include void my_sleep(int ms) { std::this_thread::sleep_for(std::chrono::milliseconds(ms)); } void display(const std::string &text) { for (int i = 0; i < text.size(); ++i) { std::cout << text[i] << std::flush; my_sleep(52); } } int main() { char nom[50]; cout << "" << endl; cout << "" << endl; cout << "" << endl; cout << "" << endl; cout << "" << endl; cout << "" << endl; cout << "" << endl; cout << "" << endl; cout << "" << endl; cout << "" << endl; display("ναℓℓ∂αяιση'ѕ α∂νєηтυяє\n"); cout << "" << endl; display("A terrible misfortune has just occurred in the peaceful kingdom of Valldarion; the evil Dragon of the Night has just awakened from a hundred-year-old sleep. You are one of the greatest knights in the kingdom, so it's up to you to defeat the monster.\n"); cout << "" << endl; display("But ... what is your name?\n"); cout << "" << endl; cin >> nom; cout << "" << endl; cout << "Good, " << nom << "." << endl; display("So you wake up one morning in the cozy room of an inn in the town of Balmora. You take your faithful Vaillante sword then your horse, ready for the long quest that awaits you.\n"); cout << "" << endl; display("You ride on horseback, crossing the city at full gallop. At the end of Balmora, you decide to go through the evil forest of Durmur, which is right in front of the mountain of the Dragon of the Night, to avoid making a detour.\n"); cout << "" << endl; display("You arrive at the edge of the evil forest at dusk. Your horse seems nervous and refuses to enter the forest after dark.\n"); cout << "" << endl; display("What are you going to do ?\n"); cout << "" << endl; cout << "1. Enter anyway." << endl; cout << "2. Redirect to another path." << endl; int tchoice = 0; cout << "" << endl; cin >> tchoice; if (tchoice == 1) { cout << "" << endl; cout << "You enter the evil forest in the middle of the night. Unfortunately for you, the Spirit of the Evil Forest stalks you and ends up finding you. He devours you even before you have unsheathed your sword. The adventure ends here, " << nom << "." << endl; cout << "" << endl; } else { cout << "" << endl; display("You arrive at the ruins cursed in the middle of the night. There does not seem to be anyone, so you decide to set up a camp for the night and let your horse rest. You watch until you sink into a deep sleep ...\n"); cout << "" << endl; display("You wake up with a start and draw your sword after hearing the characteristic cry of the Night Dragon.\n"); cout << "" << endl; display("What are you going to do ?\n"); cout << "" << endl; cout << "1. To run away." << endl; cout << "2. Take your sword and head to the source of the scream." << endl; int thchoice = 0; cout << "" << endl; cin >> thchoice; if (thchoice == 1) { cout << "" << endl; cout << "You flee but unfortunately fall on a band of goblins, who jump on you and put you in piece. The adventure ends here, " << nom << "." << endl; cout << "" << endl; } else { cout << "" << endl; display("You run to the source of the cry. In front of you is the terrible and gigantic Dragon of the Night, which rushes towards you like an evil shadow. You draw your sword and jump into battle.\n"); cout << "" << endl; cout << "After a fierce fight, you finally triumph." << endl; cout << "" << endl; display("What are you gonna do ?\n"); cout << "" << endl; cout << "1. Slice the Dragon's Head of the Night." << endl; cout << "2. Return to town and celebrate your victory." << endl; int fthchoice = 0; cout << "" << endl; cin >> fthchoice; if (fthchoice == 1) { cout << "" << endl; display("You did well. The Night Dragon was not dead yet and was about to jump on you one last time. After completing it, you return to the city and celebrate your victory in the best hostel in Balmora. щεℓℓ þℓąγεđ !\n"); cout << "" << endl; } else { cout << "" << endl; cout << "You should not have. The Night Dragon was not dead yet and jumps on you before burning you with its fiery fire. The adventure ends here, " << nom << "." << endl; cout << "" << endl; } } } } --------- Here's the executable http://bit.ly/ValldarionAdventureCPlusPlus

fallthrough

$
0
0
I'm building a project which needs to get built with VC2005 for various reasons. One of the files has a switch statement looking like this:- Code: --------- switch (argc) { case 9: if (types[8] == 'f') { linkid = (int) argv[8]->f; } else { linkid = argv[8]->i; } case 8: if (types[7] == 'f') { linkset = (int) argv[7]->f; } else { linkset = argv[7]->i; } case 7: if (types[6] == 'f') { port = (int) argv[6]->f; } else { port = argv[6]->i; } // etc } --------- Notice that there are no *break;* statements in between each case. Someone else builds the same project with gcc and he's added some *[[fallthrough]]* lines at the end of each case - i.e. Code: --------- switch (argc) { case 9: if (types[8] == 'f') { linkid = (int) argv[8]->f; } else { linkid = argv[8]->i; } [[fallthrough]]; case 8: if (types[7] == 'f') { linkset = (int) argv[7]->f; } else { linkset = argv[7]->i; } [[fallthrough]]; case 7: if (types[6] == 'f') { port = (int) argv[6]->f; } else { port = argv[6]->i; } [[fallthrough]]; // etc } --------- I don't know if later versions of MSVC would accept this but VC2005 doesn't (giving me:- *error C3409: empty attribute block is not allowed*). Obviously I could just comment out the lines but I just wondered if *fallthrough* is a valid keyword of some kind later versions of C++ ?

How to use C# dll?

$
0
0
myDLL.dll was generated from IKVM. Use in C# project is perfectly fine. HOW to: 1. call a static method in C++. in C# code, it is `com.myApp.Initialiser.initialise(object, string, int)` 2. create a new instance in C++. in C# code it is `new com.myApp.requests.MyRequest()` Code: --------- #include "stdafx.h" #include using namespace std; #include #include #include #include typedef void (*Initialise)(void*, std::string, int); int main(){ HINSTANCE myDLL = LoadLibrary(TEXT("myDLL.dll")); HINSTANCE ikvmCoreDLL = LoadLibrary(TEXT("IKVM.OpenJDK.Core.dll")); if(myDLL && ikvmCoreDLL){ cout << "dlls loaded" << endl; //how to do 1 and 2 using myDLL.dll? Initialise ptr = (Initialise) GetProcAddress(myDLL, "initialise"); //not working } return 0; } ---------

error C4013: 'InitializeSRWLock' undefined; assuming extern returning int

$
0
0
Firstly, I'm seeing this error when I try to compile a 3rd-party library. I see it with other function calls too - such as AcquireSRWLockExclusive() / TryAcquireSRWLockExclusive() / ReleaseSRWLockExclusive() and a few others. According to MSDN I should be able to fix this by #including or maybe I've tried #including both - and yet I still get the error... :( Secondly - this is VS2015 (Community Edition) but whenever I've compiled things in previous versions of MSVC, I've a feeling this was previously a warning. I've checked the project's *Propertie*s but warnings aren't set up to be treatable as errors. So might there be something in a header file somewhere which would over-ride the project setting (and thereby cause warnings to get treated as errors) ?

Can't automate Excel from Windows 10 (MFC program)

$
0
0
I'm using Visual C++ Professional Version 2015 update 3. I have a program that automates Excel and works fine in our Windows 7 computers. However, on Windows 10, Excel doesn't even launch (CreateDispatch() returns 0). There is a problem with a Windows Function, CLSIDFromProgID(L"Excel.Application", &clsid), which returns error 0x800401fe, which has the explanation: “Application was launched but it didn't register a class factory”. This is a curious explanation because all the function does is pick up the CLSID from the registry (it doesn’t launch Excel). And “Excel.Application” is in the registry for the Windows 10 computer just like for our Windows 7 computers. I was thinking that maybe Windows 10 doesn’t allow automation to work from clients that are from an “unknown publisher”, but then it should work with UAC off. (And when I ran it with UAC set to "never notify", the warning message did not appear when starting PI_Dats. Maybe it’s not really disabled, it just doesn’t issue the warning?) On the Local Disk Properties Security tab, Administrators have full control and I set Users also to full control. Any ideas as to how to automate Excel from Windows 10 would be greatly appreciated. Thanks, Gary
Viewing all 3021 articles
Browse latest View live