c

C for Java Programmer?

Possible Duplicate: Should I learn C before learning C++? As a professional (Java) programmer and heavy Linux user I feel it's my responsibility to learn some C (even though I may never use it professionally), just to make me a better coder. Two questions : Should I try C or C++ first - I realise they are different languag...

Assigning a pointer to a array of pointers to char

gcc 4.4.4 c89 #define SIZE 5 char *names[SIZE] = {"peter", "lisa", "simon", "sarah", "julie"}; char *search_names[SIZE] = {0}; size_t i = 0; for(i = 0; i < SIZE; i++ ) { search_names[i] = names[i]++; } for(i = 0; i < SIZE; i++) { printf("name to search for [ %s ]\n", search_names[i]); } I ...

please can some one help me explain linked list?

I have tried a lot to learn linked list.But all my efforts were wasted.Please can some one help me understand linked list by providing his/her own code?Thanks in advance. ...

Blank char counter in C

I am trying to create a small function that returns the number of spaces in a Char* variable using the C language. Let's say I have this string :"hello hello hello". I want the function to return 2. This is the code I have so far: int blankcounter(char* pline) { int i=0; int counter =...

fgets reads too many chars than exists

I have the following function: void writeResults(FILE* fp, FILE* fpw, Vector w, int size) { Vector x; while (1) { char line[MAX_DIMENSION]; //max dimension is 200 if( (fgets(line,MAX_DIMENSION,fp)) == NULL) { //EOF return; } else { int i=0; while (line[i]!='\0') { ...

How does rand() work? Does it have certain tendencies? Is there something better to use?

I have read that it has something to do with time, also you get from including time.h, so I assumed that much, but how does it work exactly? Also, does it have any tendencies towards odd or even numbers or something like that? And finally is there something with better distribution in the C standard library or the Foundation framework? ...

Need help with this programming problem involving flipping coins

Hello, Im trying to solve the flipping coins problem on codechef.com (http://www.codechef.com/problems/FLIPCOIN/) My code is in C, and i tested it using gcc v4.4.3 on my machine running Linux,and my program works for the sample input provided. However, on uploading to the judge i get the message "Wrong Answer". In my program i represent...

Deleting an arbitrary chunk of a file

What is the most efficient way to delete an arbitrary chunk of a file, given the start and end offsets? I'd prefer to use Python, but I can fall back to C if I have to. Say the file is this ..............xxxxxxxx---------------- I want to remove a chunk of it: ..............[xxxxxxxx]---------------- After the operation it should...

Can I add numbers with the C/C++ preprocessor?

For some base. Base 1 even. Some sort of complex substitution -ing. Also, and of course, doing this is not a good idea in real life production code. I just asked out of curiosity. ...

Error messages are not clear to me.

char name[10]="James"; //valid statement char name[10]; strcpy(name,"james"); //valid statement char name[10]; name[10]="james"; //invalid statement *name="james"; // invalid statement For above mentioned both invalid statment it says "error: assignment makes integer from pointer without a cast" The error message i...

Header Files Mystery

Possible Duplicate: what is the difference between #include <filename> and #include filename Why do we use Quotation Marks ("...") for custom build classes and braces for built in classes(<...>)? ...

WinINet trouble downloading file to client?

I'm curious why I'm having trouble with this function. I'm downloading a PNG file on the web to a destination path. For example, downloading the Google image to the C: drive: netDownloadData("http://www.google.com/intl/en_ALL/images/srpr/logo1w.png", "c:\file.png"); The file size is correct after downloading. Nothing returning false. W...

Circular queue problem

I'm learning queues from a book. I've got into a problem while learning circular queue. The author from which I'm learning uses the following piece of code to explain how an element is inserted in a circular queue. #define MAX 100 char *p[MAX]; int spos = 0; // spos: holds the index of the **next free** storage location int rpos = 0;//...

Windows port/implementation for GNU Pth (Gnu Portable Threads)

I have inherited a pure C project that uses GNU Pth ( http://www.gnu.org/software/pth/ ) and I was hoping that there was a Windows port/implementation so I wouldn't have to stick a whole bunch (more) conditionals into my code. I know I am being hopeful, but is there anything that provides the exact same function signatures and functiona...

system function in c is not working for me

I am using this code to extract a password protected rar file. I am using the system function to invoke the rar command. If I use the password in the system command, It works. But as tries to pass the password as parameter, It don't. eg if in this code if I use password pwd, it gives the error "pwd is not recognised as internal or extern...

Using SQLite with C on Windows

Hi all ! I am trying to develop a project in C (on Dev-Cpp IDE) using SQLite for data storage, on Windows Vista. I am trying to run this code : Sqlite with C I moved sqlite3.h in the /lib path. But when I am trying to run the program, I get lots of linker errors, saying "undefined reference to sqlite3_open" ,etc. Google gives me Linux...

Finding out the sum of first and the last digit of any number

I want to write a program for finding out the sum of first and the last digit of any number entered through keyboard. For example, I entered 52264. Output must be 5+4 = 9. Yes, this is an assignment. ...

Mixing C and D code in the same program?

Is it possible? i.e. compile .c with dmc and .d with dmd and then link them together, will this work? Will I be able to call D functions from C code, share globals etc? Thanks. ...

Lowest Common Ancestor of Binary Tree(Not Binary Search Tree)..

I tried working out the problem using Tarjan's Algorithm and one algorithm from the website: http://discuss.techinterview.org/default.asp?interview.11.532716.6, but none is clear. Maybe my recursion concepts are not build up properly. Please give small demonstration to explain the above two examples. I have an idea of Union Find data-str...

Addition of all digits

I want to write a program to add all the digits of the entered number. For example, when I enter 54496 the output must be 5 + 4 + 4 + 9 + 6 = 28. ...