I am making an iPhone app. I have a code that is in C. The C code contains a lot of pointers and global variables. I want to use this C code in my objective-c project. Can anybody please help me with this?
...
Hi,
I have a iPhone application with a few custom-defined colors for my theme. Since these colors will be fixed for my UI, I would like to define the colors in a class to be included (Constants.h and Constants.m). How do I do that? (Simply defining them does not work because UIColors are mutable, and would cause errors - Initalizer not ...
I'm trying to convert a string to GUID with sscanf:
GUID guid;
sscanf( "11111111-2222-3333-4455-667788995511", "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
&guid.Data1, &guid.Data2, &guid.Data3,
&guid.Data4[0], &guid.Data4[1], &guid.Data4[2],
&guid.Data4[3], &guid.Data4[4], &guid.Data4[5],
&guid.Da...
What would be the reason for the following errors though the syntax was right and I have included the coreservices framework in which some data type and constants are declared.
" c.c:22: error: syntax error before
‘CFFileDescriptorRef’
c.c:22: warning: no semicolon at end
of struct or union
c.c:24: error: syntax error b...
Let's take a simple example of two lines supposedly doing the same thing:
if (value >= 128 || value < 0)
...
or
if (value & ~ 127)
...
Say 'If's are costly in a loop of thousands of iterations, is it better to keep with the traditional C syntax or better to find a binary optimized one if possible?
...
I want to set up separate ctags databases for various libraries in /usr/include/ for use with OmniCppComplete.
The idea is to be able to pull in only the libraries needed for a particular project in the target language - C or C++.
For example, I'd like to have one database for the standard C libraries, one for system libraries that m...
Hi,
Searched through net, could't find a way to read/write file metadata using C or C++, however, there are tools available for this, and also there are API's in C# and Java to do this. But I want to do it from scratch in C or C++.
For example, read/write image metadata.
Have found out that there are three formats in which metadata is...
I'm having problems understanding why following code leaks in one case, and not in the other case.
The difference is
while(NULL!=fgets(buffer,length,file))//doesnt leak
while(NULL!=(buffer=fgets(buffer,length,file))//leaks
I thought it would be the same.
Full code below.
#include <stdio.h>
#include <stdlib.h>
#define LENS 10000
vo...
I'm trying to PUT data using libcurl to mimic the command
curl -u test:test -X PUT --data-binary @data.yaml "http://127.0.0.1:8000/foo/"
which works correctly. My options look like:
curl_easy_setopt(handle, CURLOPT_USERPWD, "test:test");
curl_easy_setopt(handle, CURLOPT_URL, "http://127.0.0.1:8000/foo/");
curl_easy_setopt(handle, CUR...
Given a vector X of size L, where every scalar element of X is from a binary set {0,1}, it is to find a dot product z=dot(X,Y) if vector Y of size L consists of the integer-valued elements. I suggest, there must exist a very fast way to do it.
Let's say we have L=4; X[L]={1, 0, 0, 1}; Y[L]={-4, 2, 1, 0} and we have to find z=X[0]*Y[0] +...
Hi,
I want to create one server and one client(two separate programs) where in server creates
two named pipes(i guess thats the minimum required for bidirectional flow of traffic) and then
the client is started,and Client and server should be able to send and recieve data both ways
all the time(full duplex types).I think that would req...
I was wondering if in C/C++ language it is possible to pass arguments to function in key-value form.
For example in python you can do:
def some_function(arg0 = "default_value", arg1):
# (...)
value1 = "passed_value"
some_function(arg1 = value1)
So the alternative code in C could look like this:
void some_function(char *arg0 = "d...
The question is a little complex. The problem here is to get rid of duplicates and save the unique elements of array into another array with their original sequence.
For example :
If the input is entered b a c a d t
The result should be : b a c d t in the exact state that the input entered.
So, for sorting the array then checking co...
typedef struct child_list {int count; char vo[100]; child_list*next;} child_list;
typedef struct parent_list
{ char vo[100];
child_list * head;
int count;
parent_list * next; } parent_list;
As you can see there are two structures. child_list is used to create a linked list. And this list will be stored in a linked list of parent list. ...
Is there any way to create a hash of string at compile time using the C/C++ preprocessor (or even template-metaprogramming)?
e.g. UNIQUE_SALT("HelloWord", 3DES);
The idea is that HelloWorld will not be present in the compiled binary, just a hash.
Edit: There are many of these declarations spread over a large codebase.
...
I want to calculate performance of a function in micro second precision on Windows platform.
Now Windows itself has milisecond granuality, so how can I achieve this.
I tried following sample, but not getting correct results.
LARGE_INTEGER ticksPerSecond = {0};
LARGE_INTEGER tick_1 = {0};
LARGE_INTEGER tick_2 = {0};
double uSec = 10000...
I have a small program that I can compile with GCC and ICC without any difficulties, but I would also like the code to work with G++ and ICPC. I tried to add this:
#ifdef __cplusplus
extern "C" {
#endif
at the beginning and this:
#ifdef __cplusplus
}
#endif
at the end of all the header files, but I still get several `undefined ...
My Struct Definitions.
typedef struct inner_list {char word[100]; inner_list*next;} inner_list;
typedef struct outer_list
{ char word [100];
inner_list * head;
outer_list * next; } outer_list;
And The problem part:
void append(outer_list **q,char num[100],inner_list *p)
{ outer_list *temp,*r;
temp = *q;
char *str;
...
I am learning c++, and I am having issues doing some newbie things. I am trying to create a very small application that takes the users input and stores it into a char array. I then parse through that array and remove all parenthesis and dases and display it. like the following
(325)858-7455
to
3258587455
But I am getting errors
err...
I have to parse this string in C:
XFR 3 NS 207.46.106.118:1863 0 207.46.104.20:1863\r\n
And be able to get the 207.46.106.118 part and 1863 part (the first ip address).
I know I could go char by char and eventually find my way through it, but what's the easiest way to get this information, given that the IP address in the string coul...