Should I set global vars value on startup or the first time I use them? C++
I have a few global vars I need to set the value to, should I set it into the main/winmain function? or should I set it the first time I use each var? ...
I have a few global vars I need to set the value to, should I set it into the main/winmain function? or should I set it the first time I use each var? ...
In C++ given an array like this: unsigned char bogus1[] = { 0x2e, 0x2e, 0x2e, 0x2e }; Is there a way to introspect bogus1 to find out is is four characters long? ...
Can a struct contain other structs? I would like to make a struct that holds an array of four other structs. Is this possible? What would the code look like? ...
I'm writing an IRC Client (yes another one). Long story short. I'm writing a Server dialogue that keeps a list of this: Identity Networks Channels Addresses I have 3 different list views that will be for the Networks, Channels and Addresses. When the user changes the Identity (combo box). The network listview will...
Hello, I'm trying to build an example of boost::asio http://www.boost.org/doc/libs/1_43_0/doc/html/boost_asio/example/echo/async_tcp_echo_server.cpp but without any luck. System: Windows Vista, Visual C++ 2008 Pro, Boost 1.43. I've added to the project, at VC, the include path and the additional lib path (see note #1), yet the linker...
#include <iostream> using namespace std; typedef struct { char streetName[5]; } RECORD; int main() { RECORD r; cin >> r.streetName; cout << r.streetName << endl; } When I run this program, if I enter in more than 5 characters, the output will show the whole string I entered. It does not truncate at 5 characters. Why...
I'm trying to use the lame_enc.dll file from LAME in a C# project, but adding the thing seems impossible. I keep getting an error that says that a reference could not be added and to please check if the is accessible, a valid assembly or COM component. I have no C++ experience, though I would like to use the functionality. Right now I'...
Made a new project, added main.cpp and wrote the code at this URL: http://www.boost.org/doc/libs/1_43_0/doc/html/boost_asio/example/echo/async_tcp_echo_server.cpp Also, added the appropriate include path. What's next?!?!! It seems like a darn mystery to build a boost code! Been digging on it for more than 10 hours. Can anyone give a...
I want to copy a string into a char array, and not overrun the buffer. So if I have a char array of size 5, then I want to copy a maximum of 5 bytes from a string into it. what's the code to do that? ...
I'm all about performance these days cause I'm developing my first game engine. I'm no c++ expert but after some research I discovered the importance of the cache and the memory alignment. Basically what I found is that it is recommended to have memory well aligned specially if you need to access them together, for example in a loop. N...
I have a header file like this: /* * APP 180-2 ALG-254/258/772 implementation * Last update: 03/01/2006 * Issue date: 08/22/2004 * * Copyright (C) 2006 Somebody's Name here * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following con...
hello! what i'm trying to do is get the free amount of physical memory allocate it and than manage it ( resizing it or delete it ) depending on what further calls to GlobalMemoryStatusEx return. and the problem : it works on 2 PCs with win 7 x64 one with 2G Ram ( on witch i was able to allocate like 1.3 GB) , the other has one 1GB RAM...
I was wondering if there was a way to run a thread on a seperate core instead of just a thread on that core? Thanks ...
Hello! Is there any fast way to determine the size of the largest strongly connected component in a graph? I mean, like, the obvious approach would mean determining every SCC (could be done using two DFS calls, I suppose) and then looping through them and taking the maximum. I'm pretty sure there has to be some better approach if I on...
I have 3 classes, 2 inheriting from the other like so: class A { public: virtual void foo() {cout << "I am A!" << endl;} }; class B : public A { public: void foo() {cout << "B pretending to be A." << endl} void onlyBFoo() {cout << "I am B!" << endl} }; class C : public A { public: void foo() {cout << "C pretendin...
I'm trying to create a set of overloaded templates for arrays/pointers where one template will be used when the compiler knows the size of the array and the other template will be used when it doesn't: template <typename T, size_t SZ> void moo(T (&arr)[SZ]) { ... } template <typename T> void moo(T *ptr) { ... } The problem is that wh...
So I know that C++ is strongly typed and was just wondering if there was any library (or any thing for that fact of the matter) that would allow you to make a variable that has no initial specific type like var in Python. ...
If I want to use extendible hashing to store a maximum of 100 records, then what is the minimum array size that I need? I am guessing that an array of 100 would be sufficient, but I could be wrong. I also suspect that I can use a smaller array. ...
I have an int that I want to first convert to a binary number. Then I want to store that binary number in a string. How can this be done? ...
Given a array of random integers, sort the odd elements in descending order and even numbers in ascending order. e.g. for input (1,4,5,2,3,6,7) Output = (7,5,3,1,2,4,6) Optimize for time complexity. ...