c

pass int to a C callback

Why i is not recognized correctly in the callback? I think that maybe because after add_strip() "i" is destroyed, so how could i pass an int to that callback? Thanks. 29 void add_strip(int i,char name[30]){ 30 sl[i] = elm_slider_add(win); 31 elm_slider_label_set(sl[i], name); 32 elm_slider_unit_format_set(sl[i], "dB"); 33 ...

Passing structures using sento()

How do I pass following message format from a UDP client to a UDP server? ----------------------------- |Ver|p|fff| length| checksum| ---------------------------- | Customer id | ----------------------------- | Amount | ----------------------------- |other | -------------------------...

uint as indices

EDIT: Originally I had transcribed i++ not i-- The code now is as it was, and the code in the code block compiles and works. Why, if unsigned int i; is used instead of int i; in the code snippet below, does using the function result in a segfault? void insertion_sort_int_array(int * const Ints, unsigned int const len) { ...

Return pointer from function C

In my C program this function is going to handle all the work of opening a specific file and then return the file pointer, so main or other functions can read the content by using fp, but so far i haven't been able to get this to work. I'm just learning the language, so it is possible that i am doing something very wrong. int open_text...

Is there a way to embed windows save dialog

The subject has it all. I want to have the Windows save as dialog as part of my own dialog. Is that even possible ? ...

Network programming: Python vs. C for a complete beginner

Hi, I am looking for a few pointers, I got pointed to this site. My primary interest is network programming. I have done quite a bit of reading and experimenting and am familiar with mechanisms of most protocols. Now I want to start writing code. I read introductory stuff on python and grasped it well too. I had just started playing wit...

[C++] Can software be developed in a different "human language" in C/C++ ?

Hi, I am developing a test software where the user can enter a string where I must validate it as C++ variable syntax. Then I started wondering if people can develop in japanese or other idioms. When I typed "is" on some IDE, it poped up a list with a "isascii" function. Then I wondered if I can use that function to check for the lett...

Effect of filling memory allocated by malloc()

Although I was able to correct my program and make it run properly, the reason why it wasn't working left me really curious. I made a string with malloc and initialized it...then I did several strcat with it...and then I declares a file pointer...after that and if my string had more than approx. 26 chars the rest would be garbage...but ...

NASM accessing sound card directly (No OS)

I'm attempting to write a very simple OS in ASM and C. (NASM assembler) I would like to access the sound card directly, with or without drivers. If I don't need drivers, how could I access and send a sample audio file to the sound card? (An example would be nice) If I do need drivers, is there anyway to interface them and call functions ...

C or Python best for learning network programming?

My primary interest is network programming. I have done quite a bit of reading and experimenting and am familiar with mechanisms of most protocols. Now I want to start writing code. I read introductory stuff on python and grasped it well too. I had just started playing with the python modules, when I met somebody (with a tall reputation)...

Is there a more efficient way of reading a formatted file in C than I have done?

Hi, I need to read in a formatted file that looks something like this. Code: HARK Name: Oscar MRTE: Train etc At the moment my code looks like this. FILE *file; char unneeded[10]; char whitespace[2]; char actual[10]; file = fopen("scannertest.txt","r"); fscanf(file,"%s",unneeded); // this is the identifier and the colon (code:) fs...

Linux multithreading would involve the pthreads library(in most cases) . What is the equivalent library used by MSVC ?

I need to know which are the APIs/library used for multithreading by MSVC . If there are more than one , please let me know which is the most widely used. If my question sounds too naive , its because I've never done threading before , and from my past experience , I know there are people here who can get me started/point me at the righ...

double free error with pointer to array of mpz_t

Hi, I'm currently learning libgmp and to that end I'm writing a small program which find prime factors. My program calls a function which fills an array with a varying amount of mpz_t integers, prime factors of a given number, which I need to return. I'm planning on setting the last element to NULL, so I know how many mpz_t integers the...

What's the best way for such strings match?

I want to analyze a message's type for best performance, the message is begin with constant string and one space followed. The constant strings belongs to one known list of string array, like "CUT", "GET", "LOGIN" ... So I do not like to memcmp(data, "GET", 3) thing repeatedly which is bad for performance. I wonder is there any better ...

Can a thread be pre-empted in the midst of a system call to kernel ?

I'm running 2 threads ( assume they are pthreads for the moment) . Thread_1() makes a user-defined API call which ultimately does some work in the kernel . Thread_2() is totally in user-space. My question is : Can Thread_2() start executing by pre-empting Thread_1() while the API call is in progress , the control is somewhere inside th...

c classes functions

Ok this may be a silly question for many of you. Let me preface this with a list in order of the languages I've learned over the past 10 years. [by the way, I understand that some of these are scripting languages] vb 6.0 html asp php css javascript managed c++ c# c++ C ASM Yeah I know I started at the complete opposite end, but hopef...

What's the difference between Pointers and Global Variables in C?

I'm reading The C Book to try and get a better foundation in C. While I think I'm generally getting the concept of pointers, one thing sticks out to me is that it seems like it's generalizing whatever it's pointing to into a global variable (e.g. the ability to use pointers to return values from void functions), which naturally carries...

greater integer width

i m trying to enter a five digit number greater than 32767 and i used "unsigned" while declaring int number, and when i m trying to print the same number it prints some arbitary negative number, results get overflowed...... pls help me out ...

Is it better to use fchmod over chmod?

Is using fchmod(int fildes, mode_t mode) a better idea than using chmod(const char * path, mode_t mode)? ...

Static allocation of huge amounts of memory inside the main function

I have a program that has to declare a huge integer array of the size 1000000 in C (using GNU GCC compiler). I tried to declare the array in two different ways. The two possible codes are : #include <stdio.h> int arr[1000000]; int main() { return 0; } and #include <stdio.h> int main() { int arr[1000000]; return 0; } The l...