c

Any suggestions on where to learn C online in preparation of learning Objective-C

I've been programming PHP & mySQL for about 8 years now. I understand and make use of modern software architectures and OOP in my projects on a daily basis. I decided I want to learn something new. I finally decided yesterday that I want to learn C and eventually Objective-C so I can begin creating Mac / iOS applications. (Would you rec...

[C] Matrix: Memory allocation question

Hello! I'm doing a program that reads from a text file in order to determine the size of the matrix (rows and cols) and respective content of the matrix. I was wondering if something like: int main() { int rows = FunctionThatReadsRows(); int cols = FunctionThatReadsCols(); int matrx[rows][cols]; return 0; } Would work? Or does it nee...

storage size of ‘names’ isn’t known

I get this error while compiling this .c source file /INIT_SOURCE_BUILD/src/names_list.c:7: error: storage size of ‘names’ isn’t known #include <stdio.h> #include "list.h" int main(){ struct List names; names->size = 3; struct ListElmt michael; struct ListElmt john; struct ListElmt adams; names->head = michael; michael->d...

Visual Studio incorrectly marking inactive code blocks when using `#ifdef`

My project has a bunch of #ifdefs. The macros used by these #ifdefs are usually passed through the command line using the '/D' option to get different build configurations. Visual studio incorrectly assumes that these macros are not defined and greys out the code blocks present inside these #ifdefs. The problem is not syntax highlighting...

Getting started with client-server networking

I'm a good programmer, but I have zero network experience. Basically, I'd like to get into client-server networking. For example, I'd like to try getting a server process going which allows clients to connect over the internet and send pings to all of the other connected clients. Then maybe I'll try developing a simple chat client, or s...

Sockets - How to find out what port and address I'm assigned

Hi, I'm having trouble figuring this out - I'm working with sockets in C using this guide - http://binarii.com/files/papers/c_sockets.txt I'm trying to automatically get my ip and port using: server.sin_port = 0; /* bind() will choose a random port*/ server.sin_addr.s_addr = INADDR_ANY; /* puts server's IP automatically ...

Pointer to an array of pointers to Linked lists

hey guys right so i have been at this problem for the last 6 hours and have been hitting google like mad to no avail. Right I need a pointer to an array. This array contains pointers to Linked lists. Im going to have to malloc it since I dont know the array size until runtime. LList **array this was my first thought but this just give...

Interfere Win32 message loop with injected DLL code (SetWindowsHookEx)

Hello everybody! After hours of penetrating Google I ended up here. I'll come straight to the point: I'm about to "refresh" my C/C++ skills and gain experience with the unmanaged world again. As a "basic" task I developed a little key logger (which are just a few lines with the Windows API) but now I want to extend it with a "stealth" f...

Implementing a generical 'map' function over arrays in C

Hi! I'm having difficulties implementing a generic 'map' function over arrays. I started with the following draft: void MapArray(void * src, void * dest, void * (f)(void *), size_t n, size_t elem) { unsigned int i = 0, j = 0; void * temp = malloc(elem); for(i = 0; i<n, i++) { temp = (f)((char *) src) + i)); for...

How to write dynamically allocated structure to file.

Hi, I have a complex structure in a C program which has many members that are dynamically allocated memory. How do I write this structure to a text / binary file? How will I be able to recreate the entire structure from the data read from the file. struct parseinfo{ int varcount; int termcount; char **variables; char **terminals; ...

Memory issues when using a circular array in a Queue

so after debugging for awhile I've come to this in my program. It's supposed to copy name into a circular array for a queue. I am not exactly sure what I am doing wrong here and could really use some help. qPtr->front is an int qPtr->numElements is an int qPtr->queueSize is an int name is a string strcpy(qPtr->name[(qPtr->front+qPtr-...

Can I please get some feedback on this `isPalindrome()` function in C?

I'm writing some useful functions in C. One of them is isPalindrome(). I figured to determine if a number is a palindrome or not, I should... get all digits in an array iterate through with two indexes - start one at 0 and one to the array count increment/decrement the indexes whilst subscripting the array whilst they match and if the...

Insertion sort debug help

The following C code doesn't work (it just clears the list): /* Takes linkedlist of strings */ static int insertSort (linkedlist *list) { linkedlist sorted; void *data; node *one, *two, *newnode; unsigned int comp, x; removeHeadLL (list, &data); initLL (&sorted); addHeadLL (&sorted, data); while (list->count) { rem...

Anyway to quickly break a word into an array of characters in objective c?

For example: NSString *strWord = "english"; The result NSArray would be something like: e n g l i s h I think is possible to do it with [NSString componentSeparatedByCharacter:somecharacter], but I don't know what that character is... I wrote something like this to extract the character: NSString *character; for (int i=0; i<[strWor...

C Shared memory database

So this is a homework assignment, and it's kind of a doozy so i'll try to TL;DR it. Basically Im making a Shared memory database with 5 files (load,query,clean,print,change) Load loads the database from a file. (students have a first name/last name/address/telephone number) Query lets someone "search" for a specific student print....well...

Calling C function from Perl within embedded C application

Ok, this is a very interesting question and there may not be any easy way to do this but figured I would throw this out there before deciding that modifying Perl is my underlying answer. So I've got a C application that calls Perl scripts in an embedded fashion. This all works fine and dandy and it's pretty awesome that I can pass info...

How to include Openssl in my project?

I have openssl directory for whole openssl code. It has some folder hierarchy. I want to use for example RSA algorithm in openssl, how can I include open-sll in my project? If I just include that directory, program cannot find all files properly. Always error about cannot find some definition or something like that. Wish I expressed it...

Save file with C fopen

I did a program in C but it does not allow to save on c:\SomeDirectory\afile.txt I'm using this: FILE* m_hFile = fopen("c:\\SomeDirectory\\afile.txt", "a+t"); fprintf(m_hFile, "testing"); fclose(m_hFile); Why that? Is there a defined folder I can save in? SomeDirectory is previously created. I'm using Windows 7 OS. ...

Save file in Windows 7

Possible Duplicate: Save file with C fopen I'm using C language to same a file in c:\SomeDirectory on Windows 7. Is there any restriction on saving a file under this directory on windows 7? I'm having trobles with saving this file on this folder, the Windows 7 doesn't allow me (even as administrator) to save the file. On wi...

how can I distribute xmlrpc-c library with my project?

in my C project I've referenced xmlrpc-c library from sourceforge.net in order to use xmlrpc-client. my question is how can I distribute this library so other users don't need to download/install package from internet. If its possible that I can distribute it with my .so file - it will be best. ...