c

How to return string array using Pinvoke

My c/c++ skills are non-existent and there's some custom string array data that needs to be returned from an old C dll fyi - The C/C++ code can be modified as needed ...

Detecting file deletion after fopen.

Hi im working in a code that detects changes in a file (a log file) then its process the changes with the help of fseek and ftell. but if the file get deleted and changed (with logrotate) the program stops but not dies, because it not detect more changes (even if the file is recreated). fseek dont show errors and eiter ftell. how i can...

How to create a makefile from a C program?

Hiya, as part of an assessment I have to hand in a code which requires a few non-standard libraries. In order to save submitting the header files and the code I would like to form a 'makefile' with the code and required add-ons sort of 'bundled' together. I have absolutely no idea idea how to go about doing this though and any suggesti...

how to get the x to the pow y in C under c99 standard

I have #include<math.h>, and I tried to use pow(x, y) and powf(x, y). but it seems neither of them are under c99 standard. and I use the command gcc -std=c99 test.c -o test to compile. what function there exists I can use? ...

strange cscope command line limitation

Cscope has eleven search input fields in interactive mode. But when I try to use it in line-oriented output mode and specify Find all symbol assignments: field using -10 switch it does not work. Any ideas? Thanks. ...

Get an IP_ADDRESS_STRING from GetAdaptersAddresses()?

GetAdaptersAddresses() will get you addresses in IP_ADAPTER_UNICAST_ADDRESS format, which is defined as: typedef struct _IP_ADAPTER_UNICAST_ADDRESS { union { struct { ULONG Length; DWORD Flags; } ; } ; struct _IP_ADAPTER_UNICAST_ADDRESS *Next; SOCKET_ADDRESS Address; IP_PREFIX_ORIGIN ...

How do I get the file HANDLE from the fopen FILE structure?

The fopen function returns a pointer to a FILE structure, which should be considered an opaque value, without dealing with its content or meaning. On Windows, the C runtime is a wrapper of the Windows API, and the fopen function relies on the CreateFile function. The CreateFile function return a HANDLE, which is used by other Windows AP...

Accessing static variable value

I have a static variable in source file test_1.c declared as: static char var1 = 0; I need to access the current value of this variable from source file test_2.c. So, I did something like: In test_1.c static char var1 = 0; volatile char var_another = var1; and in test_2.c, I declare the variable var_another as extern and access it...

Print a Histogram based on word lengths (C)

This is a K&R exercise (1-13)... "Write a program to print a histogram of the length of words in its input. It is easy to draw the histogram with bars horizontal; a vertical orientation is more challenging." The section was about arrays, and to be honest, I'm not sure I fully understood it. Everything up to this point was f...

how to create makefile cuda so it executed in CPU to test CPU flops

hi...i'm trying to count the GPU and CPU FLOPS and i've got the source from http://norma.mbg.duth.gr/index.php?id=about:benchmarks:cuda_flops i renamed it to cudaflops.cu and compile it with this makefile ################################################################################ # # Build script for project # ####################...

How to "interleave" C/C++ souce with my string (only inside functions at appropriate places)?

For example, there is the source: void func1() { func3(); if(qqq) { func2(); } func4( ); } It should be transformed to: void func1() { MYMACRO func3(); MYMACRO if(qqq) { MYMACRO func2(); MYMACRO } MYMACRO func4( ); MYMACRO } I.e. to insert "MYMACRO\n" at the end of each line...

Returning a pair of items from a function

I know all the normal ways of doing this, what I'm looking for is an article I read a long long time ago that showed how to write some crazy helper functions using inline assembly and __naked functions to return a pair of items. I've tried googling for it endlessly, but to no avail, I'm hoping someone else knows the article I'm talking ...

Scanf with spaces does not read at all

#include <stdio.h> int main(){ int i; char name[10],surname[10],id[12],dpart[20]; printf("******** ID Documentation ***********\n\n\n"); printf("1) What is your Name? \n"); scanf("%s",&name); printf("2) What is your Surname? \n"); scanf("%s",&surname); printf("3) What is your ID Number \n"); sc...

Signal Dispositions in Pthreads

The man page for pthreads mentions: POSIX.1 also requires that threads share a range of other attributes (i.e., these attributes are process-wide rather than per-thread): ... - signal dispositions ... What do "signal dispositions" mean? ...

What's the better way to read a char?

Hello, i write a little code to simply read a char from the keyboard but the program fails, why? How must i read a char? int main(int argc, char** argv) { char op; do { printf("¿Sigues?"); scanf("%c",&op); }while(op=='s' || op=='S'); return 0; } ...

Good C Programming Link

Possible Duplicate: How do I learn C? Hi friends, I am new to stack overflow and am also a beginner to C programming. Could you please suggest me some good links for C programming (Assuming Programming comes by practice suggest me a link which has good number of programs ) specially the ones related to pointers, call back fun...

open() causes program termination

Hi, I use the following program to write to a fifo: #include <iostream> #include <fstream> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> using namespace std; int main() { unlink("fifo1"); if (mkfifo("fifo1", 0666) != 0) { ...

infix to postfix

Hi all, I've been trying to figure out this problem. I have an assignment to make a basic calculator. To do so i need the instructions in postfix. I have found some code online, which worked but used gets(). I tried replacing the gets... but the program no longer works. Here is the code, i was hoping someone could find the error (usi...

C program not collecting tallies right?

I had a general question earlier and got great responses, but now (even though it's the same exercise) I have a more specific question and thought it deserved it's own Q&A page. Here's my program (not completed, but it compiles and runs ok) : #include <stdio.h> #define IN 1 // inside a word #define OUT 0 // outside a word // #define...

Programming challenges related to chemistry

I'm looking for interesting programming puzzles, problems or challenges suitable for a class of chemistry majors learning C as their first programming language. Do you have any recommendations? ...