Here is the code:
#include <iostream>
using namespace std;
extern "C" void myCfunc();
int main()
{
myCfunc();
return 0;
}
// This will link as a C function.
void myCfunc()
{
cout << "This links as a C function.\n";
}
It prints:
This links as a C function.
Why is the extern keyword used? What meaning does it have?...
What is inside .lib file of Static library, Statically linked dynamic library and dynamically linked dynamic library?
How think there is no need for a .lib file in dynamically linked dynamic library and also that in static linking, the .lib file is nothing but a .obj file with all the methods. Is it correct?
...
Text file (or CSV) is:
Data:,,,,,\n
(but with 100 ","s)
In C or C++ I would like to open the file and then fill in values between the ",".
i.e.- Data:,1,2,3,4,\n
I'm guessing that I need some sort of search to find the next comma, insert data, find the next comma insert, etc.
I was looking at memchr() for a buffer and...
I have to implement a function that takes an iterator. The iterator must dereference to a certain type, say int:
template<typename iter>
void f(iter i) {
// do something here ...
int t = *i;
// do something here ...
}
The problem with this code is that if a user calls the function like this
vector<string> v;
v.push_back("aaa"...
Im just wondering how good the MSVC++ Compiler can optimize code(with Code examples) or what he can't optimize and why.
For example i used the SSE-intrinsics with something like this(var is an __m128 value)(it was for an frustrum-culling test):
if( var.m128_f32[0] > 0.0f && var.m128_f32[1] > 0.0f && var.m128_f32[2] > 0.0f && var.m128_f...
Does it matter if I use a string or char for a simple input function? (aka y/n)
This is what I'm using at the moment:
using namespace std;
string somestr;
getline(cin,somestr);
if(somestr.empty())
{ //do something }
else if (somestr == "y"){
//do something else
}
else{}
And if it makes more sense to user char what would be the eq...
Hello,
I would like to use the GetVolumeInformation call to retrieve the name of a removable device. I can retrieve the name just fine and store into a TCHAR array variable szVolNameBuff. Here is my code for that:
// Get Volume Information to check for NTFS or FAT
TCHAR szFileSys[256];
TCHAR szVolNameBuff[256];
DWORD dwSerial ...
Given:
MY_CLASS* ptr = MY_CLASS::GetSomeInstance();
What is the correct way to output ptr to std::cerr, so I can log its value? Note I don't want to write the class, just the address.
...
I'm wondering if simply compiling my msvc project with sse/sse2 will have any effect. I do for example vector normalization and dot product but I do these wth math, not any specific function. Is there like sse_dot() and sse_normalize() that I should be using to actualyy take advantage, or will the compiler know?
Thanks
...
Hi!
I'm trying to learn C++ for Qt development, and I'm a little scared of header files. What I'd like to know is, what's the best workflow for keeping *.cpp and *.h files synched? For example, is the norm to write the class file and then copy the relevant info over to the header?
Sorry if this doesn't make any sense...I'm just lookin...
I'm writing a windows application and I needs to run some console applications from it and get their output. I tried two different approaches:
1) Using _popen(command, "rt")
2) Creating a child process with redirected output (CreateProcess(), CreatePipe())
They both work but during the execution of some command a new console window is ...
So I was teaching my friend about pointers. While doing so, I noticed that the address of two identical structs are exactly back-to-back.
struct Foo
{
int a;
};
struct Bar
{
int b;
};
Which allowed me to do this:
Foo foo; foo.a = 100;
Bar bar; bar.b = 100;
Foo *pFoo = &foo;
Bar *pBar = &bar;
(pFoo+1)->a = 200;
This overr...
I tried to use several implementations, but all of them had bugs.
Search at SO gave me http://www-igm.univ-mlv.fr/~lecroq/string/node14.html - looks nice, but this implementation gave me wrong results - sometimes it doesn't found a string.
I spent couple hours to find the bug.
Following line looks fine:
j += MAX(bmGs[i], bmBc[y[i + j]]...
I am currently writing a programming language in C/C++ as an exercise (but mostly for fun). At the moment it compiles into a list of commands that are then executed (kind of like a low-level API). Its working fantastically, however, I think it would be more exciting if instead of having a interpreter executable, having the language act...
I have the code as below. I have a abstract template class Foo and two subclasses (Foo1 and Foo2) which derive from instantiations of the template. I wish to use pointers in my program that can point to either objects of type Foo1 or Foo2, hence I created an interface IFoo.
My problem is I'm not sure how to include functionB in the inte...
Hi,
Say I have a schema which defines an element as follows:
<xsd:element name="Widget" type="tns:WidgetType" />
<xsd:complexType name="WidgetType">
<xsd:sequence>
<xsd:element name="Name" type="xsd:normalizedString" maxOccurs="1" minOccurs="1" />
<xsd:element name="Description" type="xsd:normalizedString" default="Unknown" ...
When compiling C++ with GCC 4.4 or MSVC is it possible to get the compiler to emit messages when a function is inlined?
...
I am using C++, and would like to get the permission to execute on an area of memory. Is there a way I can do this? Right now when I just try to execute it, I get an access violation error.
...
What precedence rules apply in parsing this expression:
*(c++); // c is a pointer.
Thank you.
well, I tried the following
x = *c; c++;
x = (*c++);
x = *(c++);
They appear to be equivalent
...
Is it type[]? For example, could I have
T<int[]>;
for some template T.
...