Here s what I'm doing in a nutshell.
In my class's cpp file I have:
std::vector<std::vector<GLdouble>> ThreadPts[4];
The thread proc looks like this:
unsigned __stdcall BezierThreadProc(void *arg)
{
SHAPETHREADDATA *data = (SHAPETHREADDATA *) arg;
OGLSHAPE *obj = reinterpret_cast<OGLSHAPE*>(data->objectptr);
for(unsigne...
I'm curious what the difference here is when typedefing an enum or struct. Is there any difference semantically between these two blocks?
This:
typedef enum { first, second, third } SomeEnum;
and this:
enum SomeEnum { first, second, third };
typedef enum SomeEnum SomeEnum;
Same deal for structs. I've seen both in use, and they b...
Maybe this has been asked before, but I couldn't find it. My question is simple: Does it make sense to write an application in higher level languages (Java, C#, Python) and time/performance-critical functions in C? Or at this point unless you do very low level OS/game/sensor programming it is all the same to have a full, say, Java applic...
I am following apples Core Data Utility tutorial from http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CoreDataUtilityTutorial/Articles/00_introduction.html
I have only just started it and have already encountered an error (more than likely my error, not anyone else's).
Given the code
#import <Foundation/Foundati...
Are there any plugins for visual studio (any version) or any other ide that can show you the standard library function prototypes and their (examples) , return etc for the standard c library... much like the java code helper found in eclipse if I am not mistaken (I am not a java developer but I think I saw something similar to what I des...
I am working on a project where I need to crunch large integers (like 3^361) with absolute precision and as much speed as possible. C is the fastest language I am familiar with, so I am trying to code my solution in that language.
The problem is that I have not been able to find a good implementation of any data types for representing l...
My computer is a dual core core2Duo. I have implemented multithreading in a slow area of my application but I still notice cpu usage never exceeds 50% and it still lags after many iterations. Is this normal? I was hopeing it would get my cpu up to 100% since im dividing it into 4 threads. Why could it still be capped at 50%?
Thanks
See...
Bear with me. I have not coded in c in 8 years and am totally baffled why my string manipulation is not working. I am writing a program that loops forever. In the loop I initialize two char pointers each is passed to a function that add text to the char pointer (array). When the functions are done I print the char pointer and free the tw...
I'm trying to complete the Project Euler problem found here. For some reason my function that determines whether or not a given string is a palindrome thinks "989010" is a palindrome. The funny thing is, if I directly enter that string into the palindrome function, it functions correctly. Here's my code (I'm a newb so sorry for the bad f...
Is there a way to make "worker threads" Basically I tried creating threads every time I needed them and this resulted in being slower than with 1 thread becase creating a new thread all the time is expensive. Would there be a way to create worker threads when the application first starts, then give them work when necessary?
Thanks
...
Right now I calculate it like this:
double dx1 = a.RightHandle.x - a.UserPoint.x;
double dy1 = a.RightHandle.y - a.UserPoint.y;
double dx2 = b.LeftHandle.x - a.RightHandle.x;
double dy2 = b.LeftHandle.y - a.RightHandle.y;
double dx3 = b.UserPoint.x - b.LeftHandle.x;
double dy3 = b.UserPoint.y - b.LeftHandle.y;
...
Hi,
I'm struggling to convert a C-program linked with ld, of the gnu tool-chain
to make it compile as a visual-studio (2005) project.
The program puts .data-symbols in different segments and during an
initialization phase it copies data between segments. Pointers to the
start and end of the segments are defined in the ld linker scri...
I'm now working on a software in mobile platform where memory is very small. In a I/O bottleneck function, I need read some bytes from a img file using seek operation(You can assume that seek is slower about 10 times than read directly from memmry). In my test, this function is called 7480325 times and read bytes from bytes_offset 6800 t...
I am in the process of learning C. I have a method that takes 3 strings and combines them to do some operation. Following was my first implementation using a GCC compiler.
void foo(const char *p1, const char *p2, const char *p3)
{
size_t length = strlen(p1) + strlen(p2) + strlen(p3);
char combined[length + 1];
memset(combin...
I have a bunch of C code. I have no intention to convert them into C++ code.
Now, I would like to call some C++ code (I don't mind to modify the C++ code so that they are callable by C code).
class Utils {
public:
static void fun();
}
class Utils2 {
public:
static std::wstring fun();
}
If I tend to call them with the followi...
I'm a bit confused about how Ruby handles the creation of Enumerators. Block-based iteration makes sense and is working for me; I am still confused how the return of an Enumerator is supposed to function code-wise.
Here is the code I am working with:
VALUE rb_RPRuby_Sender_Kernel_each_backtrace_frame( int argc,
...
what is mean by slack byte in structures in C. please help.
...
I have a C Library Cdll.dll which has the function
int _stdcall AddVersion(int repval)
{
return (repval + 10);
}
I am calling this AddVersion function from a VB dll.
Private Declare Function AddVersion Lib "cdll.dll" (ByVal Repval As Integer) As Integer
...
Public Function VbMessageHandler(ByRef intVal As Integer) As Integer
...
Hello,
I have functiof of load data:
GdkPixbufAnimation* load_image_from_stream(GInputStream* input_stream, GCancellable* generator_cancellable)
{
....
}
It's load very nice. Then I have function where i call load_image_from_stream:
void loading(GtkWidget* widget ,MainWin* mw)
{
GInputStream* input_stream;
input_strea...
The logic of the program is quite clear but when it asks the user to enter name. The second time it asks for the name i.e at i=1 it asks for the name and also asks for the year to be entered. In short its not allowing to the user to enter data after i=0 in int year.
/* Write a program to take input name roll number and year of joining ...