logo
down
shadow

CPP QUESTIONS

How to find the magic number of a file by just provding the path of the file using c++?
How to find the magic number of a file by just provding the path of the file using c++?
I hope this helps you . You're getting a segmentation fault because there is no such file as /root/ds/filehandling/a, and fopen thus fails, but you never even check its return value. fp is going to be nullptr, and passing that to functions like fread
TAG : cpp
Date : October 30 2020, 05:01 AM , By : Manar Abd Elkhalek
How to export function names and variable names using GCC or clang?
How to export function names and variable names using GCC or clang?
seems to work fine So you want to hide/mask the names of symbols in your binary. You've decided that, to do this, you need to get a list of them so that you can create a script to modify them. Well, you could get that list with nm but you don't need
TAG : cpp
Date : October 30 2020, 05:01 AM , By : shaina Bajaj
What is the quickest way to print a 2D array of chars?
What is the quickest way to print a 2D array of chars?
Does that help I'm trying to write a simple console game. , This should be faster:
TAG : cpp
Date : October 30 2020, 05:01 AM , By : user2177718
Should a call to WSAResetEvent after WSAEnumNetworkEvents cause event to never be set again?
Should a call to WSAResetEvent after WSAEnumNetworkEvents cause event to never be set again?
I wish this helpful for you Calling WSAResetEvent() manually introduces a race condition that can put your socket into a bad state.After WSAEnumNetworkEvents() is called, when new data arrives afterwards, or there is unread data left over from an ear
TAG : cpp
Date : October 30 2020, 05:01 AM , By : Shnitzel
File pointer only read the first entry
File pointer only read the first entry
like below fixes the issue It is because of else statement. If you want to buy the laptop from the second record of the data and so on, it will compare with the first record and will not return true. So, it will proceed to else statement and will not
TAG : cpp
Date : October 30 2020, 05:01 AM , By : Belal Quraishi
Using alias from header file in corresponding source file
Using alias from header file in corresponding source file
I wish this helpful for you A class defines a scope. How you access something in a given scope depends on whether you are writing code that's inside or outside that scope.So when you make the declaration using tileLayerVector_t = ...; within class Ma
TAG : cpp
Date : October 30 2020, 05:01 AM , By : campsec
Can I Initialize a char[] with a Ternary?
Can I Initialize a char[] with a Ternary?
it helps some times Since string literals are lvalues, you can take const references of them, which can be used in a ternary.
TAG : cpp
Date : October 30 2020, 05:01 AM , By : user2177604
C++ Metaprogramming: Generating a byte sequence based on type/value input?
C++ Metaprogramming: Generating a byte sequence based on type/value input?
To fix the issue you can do So this might be one of those "that's obviously easy" or "obviously impossible" questions.. , Something like this:
TAG : cpp
Date : October 30 2020, 05:01 AM , By : Mathias Storm
Scope of an object created inside if-condition?
Scope of an object created inside if-condition?
seems to work fine Whenever you enter a scope, a stackframe is 'created'. Everything you allocate to this local stack will be destroyed (the destructors of all local stack objects is called, in reverse order of creation) when you exit the scope. If y
TAG : cpp
Date : October 30 2020, 05:01 AM , By : Rameez Raza
Process std::map<K,V> and std::map<K,V*> in similar way
Process std::map<K,V> and std::map<K,V*> in similar way
it fixes the issue I have two types: std::map and std::map, and lot of functions, which operates with std::map . Now, I need also to process std::map objects by these functions . What is the best way to to implement processing the both types by the s
TAG : cpp
Date : October 30 2020, 05:01 AM , By : darthcz
Windows Sensor API - Unresolved external symbol for CLSID
Windows Sensor API - Unresolved external symbol for CLSID
help you fix your problem CLSID_SensorManager in defined in sensorsapi.h. To use it you must link to the associated library file: Sensorsapi.lib.You can add library via project->properties->Linker->Input->Additional Dependencies
TAG : cpp
Date : October 29 2020, 05:01 AM , By : Fernando Torterolo
Matlab trigonometric functions
Matlab trigonometric functions
hop of those help? You would want to use ./ instead of // is a matrix division ./ is a division of each element.
TAG : cpp
Date : October 29 2020, 05:01 AM , By : Christian Clayton
C++: Cannot compare double from an array of structures to another double in if function
C++: Cannot compare double from an array of structures to another double in if function
may help you . int i = 0, gr = 1; double otlichen6 = 5.5; , students[i].grupa = gr
TAG : cpp
Date : October 29 2020, 05:01 AM , By : user2177362
Uniform initialization causes runtime error in C++
Uniform initialization causes runtime error in C++
it should still fix some issue cv::Mat lookUpTable{ 1, 256, CV_8U } calls a different constructor than cv::Mat lookUpTable( 1, 256, CV_8U ). cv::Mat lookUpTable{ 1, 256, CV_8U } is direct-list-initialization and since cv::Mat has a constructor accept
TAG : cpp
Date : October 29 2020, 05:01 AM , By : Spoonshoe
Sum of partial group of {^(0),(1),……,()}
Sum of partial group of {^(0),(1),……,()}
like below fixes the issue This is not a programming problem, it is a combinatorics problem with a theoretical rather than an empirical approach to its solution. You can simply print the correct solution and not bother iterating over any partitions.W
TAG : cpp
Date : October 29 2020, 05:01 AM , By : Vanda Galen
Template in a Template of a different types problem
Template in a Template of a different types problem
it helps some times This needs to know what Foo is to compile data->val. So just move this to Foo.h
TAG : cpp
Date : October 29 2020, 05:01 AM , By : user2177233
Undefined symbol boost::system:detail::system_category_instance
Undefined symbol boost::system:detail::system_category_instance
I hope this helps . @Matthieu Brucher's hint with the variable names (Boost_ vs. BOOST_) did the trick:
TAG : cpp
Date : October 29 2020, 05:01 AM , By : user2177220
Access to a string member in C++
Access to a string member in C++
With these it helps After adding the correct includes, removing scope resolution (::) inside the class and fixing the quotation marks the code compiles
TAG : cpp
Date : October 29 2020, 05:01 AM , By : user2177216
Template: How to select smallest int type which holds n bits?
Template: How to select smallest int type which holds n bits?
wish help you to fix your issue For an own implementation of std::bitset (std forbidden) I used uint_fast32_t, since it's faster on 64bit CPUs. A review remark was to save space for small sets, e.g. bitset shouldn't use 8 bytes. The waste is even mor
TAG : cpp
Date : October 29 2020, 05:01 AM , By : greenvi
Passing command line arguments to Visual Studio using CMake for profile guided optimization
Passing command line arguments to Visual Studio using CMake for profile guided optimization
may help you . I'm using CMake for a C++ project. I'm trying to use profile guided optimization so I need to also pass command line arguments to the Release mode version of my binary. Visual Studio needs this to create a performance profile. I alread
TAG : cpp
Date : October 29 2020, 05:01 AM , By : David Barnes
Start multiple threads and wait only for one to finish to obtain results
Start multiple threads and wait only for one to finish to obtain results
may help you . If the data structure supplied to the black-box has some obvious start and end values, one way to make it finish early could be to change the end value while it's computing. It could of course cause all sorts of trouble if you've misun
TAG : cpp
Date : October 29 2020, 05:01 AM , By : user2177141
Shall structured binding to a copy of a const c-array be const?
Shall structured binding to a copy of a const c-array be const?
wish of those help The wording of the standard in [dcl.struct.bind] says:
TAG : cpp
Date : October 28 2020, 07:41 AM , By : Will Newcombe
Meyers Singleton : static keyword confusion
Meyers Singleton : static keyword confusion
Hope that helps Is static keyword mentioned in the Line 1 meaningless ? If so why ?
TAG : cpp
Date : October 28 2020, 07:41 AM , By : Vladimir
every data type reserves a memory or address in array but why don't comma(,) reserve its memory in an array
every data type reserves a memory or address in array but why don't comma(,) reserve its memory in an array
I wish this helpful for you They do not.The separators are never stored in the array. The array consists of a continous block of memmory and the datatype of the array lets us know how much of that block each element occupies as the size of the array
TAG : cpp
Date : October 28 2020, 07:41 AM , By : BrianR
c++ std::vector of functions passed as a parameter of a class method
c++ std::vector of functions passed as a parameter of a class method
it should still fix some issue If you can use C++11+, than you can use std::function and std::bind, or lambda.So, something like:
TAG : cpp
Date : October 28 2020, 07:41 AM , By : user2176933
Default parameters in constructor gives compile time errors
Default parameters in constructor gives compile time errors
This might help you Default values for parameters should go into the declaration, not the definition:
TAG : cpp
Date : October 28 2020, 07:41 AM , By : Dom
C++ set iterator error: no match for ‘operator+=’
C++ set iterator error: no match for ‘operator+=’
hop of those help? Only certain categories of iterator allow you to directly perform arbitrary arithmetic, like end-1.The iterator of a set permits going forwards and backwards one step at a time, using it++ and it--. It is true that it - 1 still onl
TAG : cpp
Date : October 28 2020, 07:40 AM , By : Jonny Smith
Can I get the size of a dynamicly allocated array the way `delete[]` does?
Can I get the size of a dynamicly allocated array the way `delete[]` does?
wish helps you My conclusion is:The size of the array might be stored in memory, but it is not necessarily the case; there are other ways of achieving the desired behavior, each with its own trade-offs and ISO specifically gives the compiler writers
TAG : cpp
Date : October 28 2020, 07:40 AM , By : user2176833
properly rendering an SDL rectangle to the screen
properly rendering an SDL rectangle to the screen
hope this fix your issue Why do you need to call SDL_SetRenderDrawColor() twice and why in that order?
TAG : cpp
Date : October 28 2020, 07:40 AM , By : ilja
STL not release memory from System level
STL not release memory from System level
wish of those help This is completely normal. That's how operating systems work. If they spent all their time reclaiming tiny portions of memory from tiny processes, they'd never do anything else.You just have to trust that their complicated algorith
TAG : cpp
Date : October 28 2020, 07:40 AM , By : Harsh Patel
Passing multidimensional array back through access members
Passing multidimensional array back through access members
I hope this helps . Return an object, not a naked array. The object can have a copy constructor, destructor etc. which will do the copying, deletion etc. for the user.
TAG : cpp
Date : October 27 2020, 03:37 PM , By : user3847974
About GDI/GDI+ coordinate compatibility?
About GDI/GDI+ coordinate compatibility?
around this issue Short answer: call graphics.SetPageUnit(Gdiplus::UnitPixel)I had the same problem as https://stackoverflow.com/a/4894969/700027: when printing, the coordinates for GDI+ (Gdiplus::Graphics) did not match the coordinates from GDI (HDC
TAG : cpp
Date : October 27 2020, 03:37 PM , By : sachin tiwari
What's the difference between these two object instantiation approaches?
What's the difference between these two object instantiation approaches?
This might help you Object a has automatic storage duration so it will be deleted automatically at the end of the scope in which it is defined. It doesn't make sense to attempt to delete it manually. Manually deletion is only required for objects wit
TAG : cpp
Date : October 27 2020, 03:37 PM , By : Vivek Kumar Singh
How could a member method delete the object?
How could a member method delete the object?
wish helps you I am currently studying COM and the following code confused me. , Change your main's body to:
TAG : cpp
Date : October 27 2020, 03:37 PM , By : Armen Chakhalyan
whats wrong with this program
whats wrong with this program
wish helps you , There's several problems:
TAG : cpp
Date : October 27 2020, 03:37 PM , By : user3847947
Using .lib and .dll files in Linux
Using .lib and .dll files in Linux
seems to work fine The best thing would be to get the DLL compiled on Linux as a .so and use that instead. Linux does not need the equivalent of a .lib to access shared objects.
TAG : cpp
Date : October 27 2020, 03:37 PM , By : user3847944
how to define a class using c++
how to define a class using c++
Hope this helps I need to define a class to hold stock data in c++. At minimum it needs a method for "meanvalue", a method for "vairance", and properties for "trading volume" and other historical data. , Here's a start:
TAG : cpp
Date : October 27 2020, 03:37 PM , By : Bhwthinktank
C++ How to read in a text file and reverse the lines so it reads from bottom up
C++ How to read in a text file and reverse the lines so it reads from bottom up
I hope this helps you . Please help I'm new to C++ , How about:
TAG : cpp
Date : October 27 2020, 03:37 PM , By : user3847893
how do i make this so everything can use it? C++
how do i make this so everything can use it? C++
will be helpful for those in need If I understand your question correctly you want to implement some kind of caching. That would be fine and you can create a cahe with an std::map.You would probably have something like:
TAG : cpp
Date : October 27 2020, 03:37 PM , By : user3847886
Exporting a C++ class from a .SO ( linux )
Exporting a C++ class from a .SO ( linux )
hop of those help? By default all symbols are visible in a linux shared library. So everything you would need to use the class from another program is already exported.Usually c++ classes can't be used directly by other languages, but there are sever
TAG : cpp
Date : October 27 2020, 03:37 PM , By : user3847878
intellisense for empty Win32 projects
intellisense for empty Win32 projects
I hope this helps . Usually you can fix intellisense by simply restarting Visual Studio or waiting some time.If that still doesn't work you can delete the NCB file.
TAG : cpp
Date : October 26 2020, 11:52 AM , By : Benjamin Vockenberg
Parsing mathematical functions of custom types
Parsing mathematical functions of custom types
Does that help Please checkout muparser
TAG : cpp
Date : October 26 2020, 11:52 AM , By : Amed
Android play raw Audio from C++ side
Android play raw Audio from C++ side
I wish this help you I recommend you pass the audio through the JNI and see how it actually performs. I've found that the JNI is actually quite efficient (if implemented correctly) and wouldn't be surprised if it is more than fast enough for what you
TAG : cpp
Date : October 26 2020, 11:52 AM , By : user3848126
How to access Active Directory using C++Builder?
How to access Active Directory using C++Builder?
I think the issue was by ths following , Why not just use the SDK API for AD? Active Directory Service Interfaces Reference. There are examples for most common operations at Using Active Directory Service Interfaces
TAG : cpp
Date : October 26 2020, 11:52 AM , By : Anamika
String statements
String statements
seems to work fine Talking about strings in C++, what is the difference between the following statements: s1=s2 and strcpy (s1, s2)? Supposing that s1 and s2 are (original version: type 'char', as revised) type char *. , Given:
TAG : cpp
Date : October 26 2020, 11:52 AM , By : Simon Hintersonnleit
Instruction-Level-Parallelism Exploration
Instruction-Level-Parallelism Exploration
wish of those help The problem is that deciding whether an instruction will be executed in parallel is quite difficult considering how many different processor types there are. A good understanding of the CPU architecture you are targeting will give
TAG : cpp
Date : October 26 2020, 11:52 AM , By : leachy14
Select from SQLite with Qt
Select from SQLite with Qt
I think the issue was by ths following , The isValid() method returns true if the query is positionned on a valid record, but after calling exec(), it isn't : you have to move to a valid record first, for example with query.first() or query.next(). S
TAG : cpp
Date : October 26 2020, 11:52 AM , By : user3848040
Dynamic Memory Allocation
Dynamic Memory Allocation
hop of those help? You don't have to know the size of the array in advance, or over-allocate memory to account for large arrays. This allows your program to be more efficient with its memory use.
TAG : cpp
Date : October 26 2020, 11:52 AM , By : Kenta Kume
Maximum number of characters in a string
Maximum number of characters in a string
I wish did fix the issue. For std::string str you can get maximum size as str.max_size().To get currently allocated size use str.capacity().
TAG : cpp
Date : October 26 2020, 11:52 AM , By : user3848026
Float Values as an index in an Array in C++
Float Values as an index in an Array in C++
help you fix your problem The float value will be casted to int (it can give warning or error depending on compiler's warning level)
TAG : cpp
Date : October 26 2020, 11:52 AM , By : user3848018
Is 'using namespace std;' a standard C++ function?
Is 'using namespace std;' a standard C++ function?
will be helpful for those in need No. It's what's called a using directive. I's outlined in §7.3.4 in the standard:
TAG : cpp
Date : October 26 2020, 11:51 AM , By : user3848298
Building a suffix tree in C++
Building a suffix tree in C++
wish helps you It doesn't look like you are checking the pointer iterator for NULL at all, you are simply dereferencing it (which will cause drama if it is NULL).Here's a sample to try, with the check for NULL hoisted out of the for loop:
TAG : cpp
Date : October 26 2020, 11:51 AM , By : Lina
Passing ifstream to a function in C++
Passing ifstream to a function in C++
wish helps you I'm trying to build 16 different suffix trees for a gene sequencing project. They're being built in main as such , Have you included the fstream header?
TAG : cpp
Date : October 26 2020, 11:51 AM , By : Ebrahim Hassan
Where would you use a friend function vs. a static member function?
Where would you use a friend function vs. a static member function?
I wish this help you Section 11.5 "The C++ Programming Language" by Bjarne Stroustrup states that ordinary member functions get 3 things: access to internals of class are in the scope of the class must be invoked on an instance
TAG : cpp
Date : October 26 2020, 11:51 AM , By : Kenneth Yip
Invalid free while performing a std::string assign with -O2 set in g++
Invalid free while performing a std::string assign with -O2 set in g++
may help you . If it's not guarantied that split doesn't return empty vector I'd add a check if it's empty. Otherwise assigning back() of empty vector to a string could lead to the behavior that you receive.
TAG : cpp
Date : October 26 2020, 11:51 AM , By : Dreamer
Shutting down multithreaded NSDocument
Shutting down multithreaded NSDocument
may help you . The best possible way is for the threads to own the objects necessary for the thread to finish doing whatever it is doing to the point of being able to abort processing and terminate as quickly as possible.Under non-GC, this means a -r
TAG : cpp
Date : October 26 2020, 11:51 AM , By : jithender
C(++) malloc confusion
C(++) malloc confusion
This might help you I'm just not getting any further with allocating memory for arrays in C and mainly C++. I've looked for examples but there aren't any useful ones for me out there, at least it seems so. , Use vector to do the job.
TAG : cpp
Date : October 25 2020, 07:29 PM , By : ttte
Portable c++ atomic swap (Windows - GNU/Linux - MacOSX)
Portable c++ atomic swap (Windows - GNU/Linux - MacOSX)
hop of those help? There's a lock-free library pending review in boost. Also if you dig into source of boost smart pointers library you will find atomic ops inlined for multiple platforms. Another one - Intel Threading Building Blocks has implementat
TAG : cpp
Date : October 25 2020, 07:29 PM , By : Abdelhak
C++ array initialization
C++ array initialization
wish helps you How memory is reserved depends on where the array declaration is declared. If it is declared in global scope (i.e. outside a function) then the 800 bytes (assuming an integer is 32-bits long) is made available to the whole program imme
TAG : cpp
Date : October 25 2020, 07:29 PM , By : user3848455
How (i.e. what tool to use) to monitior headers sent by Curl (Cookie problem)
How (i.e. what tool to use) to monitior headers sent by Curl (Cookie problem)
Hope that helps You can use Wireshark (the former Ethereal) to view all the network traffic a machine is sending and receiving.
TAG : cpp
Date : October 25 2020, 07:29 PM , By : user3848422

shadow
Privacy Policy - Terms - Contact Us © bighow.org