c

How can I find out all the dates of a given day in this month?

Hello Experts, I have to write a program in C which, given the name of a day, returns all of the dates in this month that the day will be on. For example, if the input is "Sunday" the output should be: 5,12,19,26 (which are the days Sunday will be on this month.) Does any one have any idea how to do this? I have tried a lot. Please he...

C corner case and trap.

I am surprised why this works? short main [] ={}; This is the only content in the file. It compiles correctly on gcc. But when i run it prints segmentation fault. When i rename main, compiler gives errors. Can anyone explain me what is going on here. ...

FAT File system and lots of writes

I am considering using a FAT file system for an embedded data logging application. The logger will only create one file to which it continually appends 40 bytes of data every minute. After a couple years of use this would be over one million write cycles. MY QUESTION IS: Does a FAT system change the File Allocation Table every time a fil...

sprintf fails spontaneously depending on what printf and NSLog calls there are.

Hello I have a bizarre problem with sprintf. Here's my code: void draw_number(int number,int height,int xpos,int ypos){ char string_buffer[5]; //5000 is the maximum score, hence 4 characters plus null character equals 5 printf("Number - %i\n",number); sprintf(string_buffer,"%i",number); //Get string printf("String - %s\n...

To "head" or NOT to "head"?.

I have a "pointer" which keeps incrementing and I need to return the "head" of the pointer finally. I am in a dilemma to use either "pointer[0]" or have another variable called "head" and initialize it and return at the end. The former I feel makes the code looks soiled and later costs little memory. Any clean suggestion? ...

How to Find a current day in c language?

Hello Expert, I am able to get the current date but the output is like 9/1/2010,but my requirement is to get the current day like"Wednesday" not in form of integer value like 1. My code is here. #include <dos.h> #include <stdio.h> #include<conio.h> int main(void) { struct date d; getdate(&d); printf("The current year is: %d\n", d.da_y...

My allocated memory is beeing written to

Im writing a project in Objective-C but I'm relying quite much on plain old C since there's OpenGL involved. I have a data blob that I read to memory from a file in the following way: NSString *path = [[NSBundle mainBundle] pathForResource:@"iPadTest" ofType:@""]; NSFileHandle *file = [NSFileHandle fileHandleForReadingAtPath:path]; dat...

Where can I find programs for practicing C and assembler(IA32)?

Guys I'm a novice. I have learnt C and Assembly(IA32) on Linux and I will also be learning a few more languages this year. I want to make my fundamentals strong and for that I need some tips from you guys as in, where will I find programs for practice? so that I solve them and get more and more experience. Any good web links that would...

matrix multiplication

Source code for matrix multiplication using pointer, dynamic memory allocation and then store them(all the three Matrix) in a file. ...

Pointer mismatch for actual parameter?

I have a function which creates an array of pointers. The function which allocates the memory returns the new memory pointer through a parameter passed to the function. The simplest code which can reproduce the problem is as follows: void foo (void** new_mem, size_t bytes) { *new_mem = malloc(bytes); } int main (void) { int**...

strcpy in a struct gives SIGABRT

Hi, I'm currently working on an FTP client written in C, and it's working pretty good. I was successful in writing a function that connects to an FTP server and logs in with a username or password, but I'm having a problem with returning errors. I have setup a struct FTPError {}; with 3 fields: int An error code int An FTP error domain...

Is there a way to package a python extension written in C into a binary so I don't have to python-install it?

I wrote a Python extension in C, and my python program uses that extension. In order for it to work, I would have to install the extension on the user's system before my program can run. Is there a way to bypass that installation step and somehow just have the extension in my python package? The only compiled part obviously is the extens...

How to find number of Multiples of 3

This was a contest Q: There are N numbers a[0],a[1]..a[N - 1]. Initally all are 0. You have to perform two types of operations : Increase the numbers between indices A and B by 1. This is represented by the command "0 A B" Answer how many numbers between indices A and B are divisible by 3. This is represented by the command "1 A B"....

readdir() fails in reading .FS_info.

Hi, This is regard to reading a directory .FS_info. using readdir(). I am trying to read this .FS_info. directory and readdir() fails to do that. How can I read this special directory successfully? Thanks in advnace. Regards Nanjappan K S ...

Is there any library that gives access to PC (windows) microphone in a way Open CV gives access to camera?

So in Open CV we have such easy way of getting to some camera device and its data: #include "cv.h" #include "highgui.h" #include <stdio.h> // A Simple Camera Capture Framework int main() { CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY ); if( !capture ) { fprintf( stderr, "ERROR: capture is NULL \n" ); getchar(); re...

How do I create a timer using the time.h library?

This is not a homework, it's more of a challenge from our prof but I'll be tagging it as one nonetheless. The problem is to create a typing game that has 3 levels with matching difficulty, different time limits (in seconds) and scores. Now I don't have any problems with the program itself, what I'm having problem is implementing the tim...

Want to Join K&R Study Group?

Hello All, Someday I want to be a computer scientist. Right now I'm looking for a few good men, women, girls, boys, cats, dogs, fish ... anybody ... anybody? I've completed all the exercises in Chapter 1 of Kernighan & Ritchie's "The C Programming Language - ANSI C" (more or less independently) and wish to work through the rest of the ...

Smart Pointer Implementation in C

Possible Duplicate: Smart pointers/safe memory management for C? I have an embedded application where I am allocating an object in dynamic memory and passing it around to other modules. I would like to create a smart pointer to this object. There are many examples in C++ for using and implementing smart pointers. I am l...

Do you have any experience teaching C to undergraduate students with the K&R book?

Has anyone had any experience in teaching programming in C to undergraduate students, who can be presumed never to have seen an editor before in their lives? I might soon face that predicament, and was thinking of basing myself on the K&R "The C Programming Language" book. Has anyone had a similar experience? What are your ideas/recomme...

Conditional jump or move depends on uninitialised value(s)

Hi friends, i'm breaking my head for hours on the following problem: i pasted 2 functions althought there are many more. i run valgrind on my program and i get 32 errors similar to this: ==4214== 6 errors in context 8 of 10: ==4214== Conditional jump or move depends on uninitialised value(s) ==4214== at 0x40088F: getNextFreeCell (in ...