c

Write a function int mystrlen(char *s) that returns the number of characters in a string wuthout strlen func.

heres what i did, i just have ne error that i cant figure out. int mystrlen(char string[]) { char string1[LENGHT], string2[LENGHT]; int len1, len2; char newstring[LENGHT*2]; printf("enter first string:\n"); len1 = mystrlen(string1); printf("enter second string:\n"); len2 = mystrlen(string2); if(len1 == EOF || len2 == EOF) ex...

How to format printf statement better so things always line up

I have this printf statement: printf("name: %s\t" "args: %s\t" "value %d\t" "arraysize %d\t" "scope %d\n", sp->name, sp->args, sp->value, sp->arraysize, sp->scope); It's inside a for loop, so it's printing multiple lines for a list of pointers. The proble...

count the number or characters in the string

I need to count the number of characters in the string without using the strlen function. int mystrlen(char *s) { char s[]=”program”; int counter = 0 ; int i; for (i = 0; i < s[i]!= 0; i++) { counter++; } printf( "The number of characters is %d", counter); return 0; ...

Visual Studio 2008 Intellisense with struct keyword

I am using visual studio 2008 express edition. A normal win32 console C project with the code below: int main(void) { struct _addr_info { char name[30]; char street[40]; char city[20]; char state[3]; unsigned long int zip; } addr_info; addr_info.zip = 12345; return 0; } Generally for structures intellisense will list the mem...

Interview questions to assess Linux C programmers

Hi Guys, I'm not quite a c programmer and I'm not joking that I'll interview a guy with 3 years experience in c under linux . in his cv, he said he is quite experienced with c programming under linux . so my question is if you are goning to this "c linux" guy, what question or questiones you will ask to make sure that this guy does hav...

How to delete structure entries in C

I have a list of structures and I want to delete some of them. I don't want to leave any empty space where the structures are deleted. I tried it with this code, but it didn't work. struct symtab *sp; for(sp = symtab; sp < &symtab[NSYMS]; sp++) if(sp->scope == scope) // delete { sp = sp+1; ...

Paged ldap_search in OpenLDAP to get around size limit?

Hi there! We are currently in the process of migrating from an aged proprietary directory service to OpenLDAP. Today we ran into the problem that ldap_search_ext_s or ldapsearch in general does not return any results, if the number of entries, which were to be returned by the current search, would hit a certain limit. Unfortunately set...

gprof : How to generate call graph for functions in shared library that is linked to main program

Hi, I am working on Linux environment. I have two 'C' source packages train and test_train. train package when compiled generates libtrain.so test_train links to libtrain.so and generates executable train-test Now I want to generate a call graph using gprof which shows calling sequence of functions in main program as well as those in...

What is wrong with this c code?

Hello there, I'm trying to replace the first line with spaces, what is it that is wrong here? #include <stdio.h> int main(void){ char text[5][10]={ {'a','a','a','a','a','a','a','a','a','\0'}, {'a','a','a','a','a','a','a','a','a','\0'}, {'a','a','a','a','a','a','a','a','a','\0'}, {'a','a','a','a','a','...

strange output in comparision of float with float literal

float f = 0.7; if( f == 0.7 ) printf("equal"); else printf("not equal"); Why output is -> not equal ???? Why is happens so ? ...

C, HTML and CGI

Hi , I have a functionality written in C. I have to give input through the html page and the operation to be processed in C (on submit of a button) and the result has to be given to the same html page. Please help me out by given some simple examples. ...

is pwrite after dup race safe?

On Linux pwrite operation (which is seek+write) is atomic, meaning doing pwrite-s in multiple threads with one file descriptor is safe. I want to create file descriptor duplicate, using dup(). Now, having fd1 and fd2 - will pwrite-s work as expected, or there's danger of race condition? ...

Dynamically creating functions in c

hi, how can i dynamically create a function in c? I try to summarize my C problem as follows: i have a matrix and i want to be able to use some function to generate its elements function has no arguments hence i define the following : typedef double(function)(unsigned int,unsigned int); /* writes f(x,y) to each element x,y of the m...

passing functor as function pointer

I'm trying to use a C library in a C++ app and have found my self in the following situation (I know my C, but I'm fairly new to C++). On the C side I have a collection of functions that takes a function pointer as their argument. On the C++ side I have objects with a functor which has the same signature as the function pointer needed b...

[C] How to conditionally determine which functions are called at compile time?

I'm working on implementing a very, very basic component system in C, but now I am at a point where I want to 'dynamically' call some functions. The set-up is very easy: the main program is simply an endless while loop, in which some conditions are checked and in which a "process" function is called for each enabled component. For examp...

storing two shorts in one short

I recently wrote some code that uses the same unsigned short to store two values, a result and an id, for example: unsigned short data = new_id(); // result is either 0 or 1 so store it in the rightmost bit and move the id left data = (data << 1) + get_result(); // ... later ... // now we can print results like printf("%u: %u\n", data &...

Windows 7 Menu Bitmaps inconsistencies

I am currently adjusting a Windows Applications GUI for Windows 7. I find a (although rather cosmetic) problem with icons in menus: In XP i use Bitmaps do identify menus which are checkable. We supply a separate Bitmap for checked/unchecked state. The bitmaps have a size of 13*13 pixels: In Windows 7 though all checked Menus have a r...

How to remove punctuation from a String in C

I'm looking to remove all punctuation from a string and make all uppercase letters lower case in C, any suggestions? ...

Size of a structure in C

Possible Duplicate: Why isnt sizeof for a struct equal to the sum of sizeof of each member? Consider the following C code: #include <stdio.h> struct employee { int id; char name[30]; }; int main() { struct employee e1; printf("%d %d %d", sizeof(e1.id), sizeof(e1.name), sizeof(e1)); return(0); } The out...

SSL wrapper stream in C

I have a simple stream_t type in C with your basic read/write operations, and support for multiple underlying implementations using function pointers. So a stream could be backed by a file, a char buffer, etc. One stream type is a standard POSIX socket, and I would like to code a wrapper stream that will add SSL support to an existing s...