c

compiler says declaration missing ;

I am having two minor problems in this code but i am unable to get them. i have mentioned on the places the compiler is giving error.There are two of them given below: #include<stdio.h> #include<conio.h> #include<stdlib.h> #define SIZE 100 int count; void menu(void); void input(int[]); void print(int[]); void insert(int[]); void delete...

Porting shared library ELF projects in autoconf to OS X

How do I use autoconf macros to conditionally change values in a configure-script or Makefile it ouputs through AC_OUTPUT. The goal is to use AC_CANONICAL_TARGET, or some other way, to identify that I'm on OS X and then allow my Makefiles to adapt the LDFLAGS by removing -shared and replacing -soname with -dylib_install_name. So I ba...

Problem with getpwuid() and stat()

I have the following code. It gives me a problem with free memory, but I haven't figured out what exactly the problem is. It seems that getpwuid(buf->st_uid); is not getting along with readdir(dirh); or with stat functions. Does anyone know why? buf = (struct stat*) malloc(sizeof(struct stat)); for (dirp[i] = readdir(dirh); dirp...

What should I #include to use 'htonl'?

I want to use the htonl function in my ruby c extension, but don't want to use any of the other internet stuff that comes with it. What would be the most minimalistic file to #include that is still portable? Looking through the header files on my computer, I can see that either machine/endian.h or sys/_endian.h would let me use them, alt...

Find the rightmost occurrence of a string t, in a string s.

Corrected code: int strrindex(char *s, char *t) { int i, j, k, p; i = -1; for (k = 0; s[k] != '\0'; k++) { if (strlen(s) < strlen(t)) break; if (s[k] == t[0]) { for (p = k; s[p] != '\0'; p++) { j = p; while (s[j] != '\0' && s[j] == t[j-k] && t[j-k] != '\0') { j++; } if (t[j-k] != '\0') { break; ...

How to learn C these days?

Possible Duplicate: The Definitive C Book Guide and List A friend of mine needs to learn C as a prerequisite for a course he is taking. My knee-jerk response was K&R, but this is a 20-year old book we're talking about. There are quite a few newer books on C, but I haven't read any of them and don't have an opinion. Any recomme...

int array size changes

Possible Duplicate: Sizeof an array in the C programming language? Why is the size of my int array changing when passed into a function? I have this in my main: int numbers[1]; numbers[0] = 1; printf("numbers size %i", sizeof(numbers)); printSize(numbers); return 0; and this is the printSize method void printSize(int numb...

What's wrong with this function?

The compiler complains about this: int randomSort(id obj1, id obj2, void *context) { // first line return (arc4random()%3 - 1); } in first line: _cmd undeclared and 'self' undeclared (first use in this function) When I not use arc4random() here, i.e. just return 1, everything is fine. I have other c functions in th...

password in c programming, where do i place the function call for another function if the password is correct

#include<stdio.h> #include<conio.h> char pw[25],ch; int i; main() { printf("\n\nEnter password"); while(1) { if(i<0) i=0; ch=getch(); if(ch==13) break; if(ch==8) { putch('\b'); putch(NULL); putch('\b'); -i; continu...

Type for array index in C99

What type for array index in C99 should be used? It have to work on LP32, ILP32, ILP64, LP64, LLP64 and more. It doesn't have to be a C89 type. There are 5 candidates: size_t ptrdiff_t intptr_t / uintptr_t int_fast*_t / uint_fast*_t int_least*_t / uint_least*_t There is simple code to better illustrate problem. What is the best type...

GDkPixBufAnimation load problem

Hello, I need to run function in another thread then main form: I have a job_func: void job_func(GIOSchedulerJob *job, GCancellable *cancellable, gpointer user_data) { MainWin* mw = (MainWin*)user_data; while( g_cancellable_is_cancelled(mw->generator_cancellable) == FALSE) { loading (NULL, mw); } } Then load...

When must I use malloc to allocate memory?

1) For which datatypes must I allocate memory with malloc? For types like structs, pointers, except basic datatypes, like int For all types? 2) Why can I run this code? Why does it not crash? I assumed that I need to allocate memory for the struct first. #include <stdio.h> #include <stdlib.h> typedef unsigned int uint32; typedef st...

Simple-iphone-image-processing source code question, what does this do

Hi, I am going through the source code for the above project and I don't understand the following lines of code can anyone help explain it to me please? I am trying to get the code to work with color images as it currently only works with greyscale images. I have the main methods working however the filters only get applied to the top qu...

char [1024] vs char *

Hi, I am trying to study C, and I am running in to troubles using char* and char arrays. I am using a generic hash-set container from a library (which I don't want to describe in details). This library includes the function void *HashSetLookup(hashset *h, const void *elemAddr); which I have to use to search in the hash set to see if t...

How can i better understand the kernel c programming code

I was studying the Kernel Architecture and its programming to get the idea about Kernel. I know C programming but the structures and pointers mentioned in kernel code are going over my head. Like below int irq = regs.orig_eax & 0xff; asmlinkage int handle_IRQ_event(unsigned int irq, struct pt_regs *regs, ...

Is quick sort followed by binary search faster than linear search?

Is it better to sort then binary search or simply linear search? Thanks ...

Maintain C projects in Visual Studio 2010?

Hello! Do you know of any extension (desired free) for VS (or VCPP) 10 that adds C projects productivity (i.e. templates, headers control, syntax highlighting etc.)? Thanks ...

how to master c

what should I do to master the c programming language ...

C/C++: Pointers within Const Struct

How do I force const-ness of the memory pointed to by obj->val1 in the function fn? #include <iostream> struct foo { int* val1; int* val2; int* val3; }; void fn( const foo* obj ) { // I don't want to be able to change the integer that val1 points to //obj->val1 = new int[20]; // I can't change the pointer, *...

GlBufferDataARB is giving me memory issues

Basically I do something like this: GenerateLinePoly(Contour[i].DrawingPoints, Contour[i].Outline.OutlineWidth); Contour[i].Outline.OutlineSize = OutlineVec.size() / 2; glBindBufferARB(GL_ARRAY_BUFFER_ARB,Contour[i].Outline.OutlineVBO); glBufferDataARB(GL_ARRAY_BUFFER_ARB,sizeof(GLfloat) * OutlineVec.size(), &Outlin...