c

C/math model of a transistor.

I'm look at writing some code to simulate some electronics and need to model some transistors. Does anyone know of a resource that has models for several kinds? (Or at least several kinds with high gate impedances and fairly linear analog performance as that's what I'm going to need.) Systems of equations and tables of values for stock ...

How can I check if a signed integer is positive?

Using bitwise operators and I suppose addition and subtraction, how can I check if a signed integer is positive (specifically, not negative and not zero)? I'm sure the answer to this is very simple, but it's just not coming to me. ...

Add GCC options to top of C source file

Is is possible to put something at the top of the C source file, like // GCC_OPTIONS=-g,-Wall that will add those options automatically to gcc every time you compile this file? ...

in which segment of the program are function pointers stored?

Hi, I wanted to know in which section of the program are function pointers stored? As in, is it on the program stack or is there a separate section for the same? void f(void){} int main(void){ int x[10]; void (*fp)(void) = NULL; fp = f; return 0; } Now, will the address of x and fp be in the same segment of the program's stack me...

Efficient mapping of users to sockets

I'm debating on how to map a User struct to their socket file descriptor. I was considering keeping an array of void pointers of a MAX_CONNECTIONS size, and storing the pointer as the value for the key of the file descriptor. The issue I run into is how I plan on handling my receives. I currently call pipe() to make a pipe, and then for...

C Programming Input Error

int main(void) { char *input; printf("prompt>"); scanf("%s", input); printf("%s", input); return 0; } prompt>input RUN FAILED (exit value 138, total time: 3s) What's wrong with the code? Has to be either the scanf() or the second printf(). The input is of unknown length. A lot people have said to simply create a c...

How to have macros expanded by doxygen, but not documented as a define?

Say I have: #define MY_MACRO(FOO) void FOO(); MY_MACRO(hi); MY_MACRO(hey); MY_MACRO(hello); #undef MY_MACRO I want the macros to be expanded by doxygen, which I am able to do by configuring it the right way: ENABLE_PREPROCESSING = YES MACRO_EXPANSION = YES EXPAND_ONLY_PREDEF = YES EXPAND_AS_DEFINED = MY_MACRO Th...

Why does compilation of this simple C++ program using 'cpp' fail?

Hello everyone, I am a beginner in C++ I am average at C. I have written the following code in C++ (file.cpp) #include <iostream> int main(){ std::cout<<"My name is ANTHONY"; } Then I tried to compile the above code using cpp file.cpp but got some errors. I don't know whats wrong When I tried to compile my C program (changed <...

How to compile '97 C codes using Motif?

Hi I'm trying to compile about 30 C sources written in 1997. Based on required header files such as XmAll.h and Xlib.h and the use of "Widget" syntax, I found that these sources depend on the Motif programming tool kits, so it seems they should be compiled in Linux or Unix system. I have no any experience with X Windows Programming and ...

Arraylist in C.

HELLO WORLD, GUYS!!! I am currently writing a program to implement an arraylist (or dynamic array) in C. Hmm... I think I have 70 - 80% done with it, however, I found a serious problem with my codes when testing them on a couple of machines. Briefly, I inserted a group of strings( char* ) into my arraylist, and tried to get and display...

undefined symbol `MPI_recv'

when i am running my mpi program written in c language.It is giving error "undefined reference to `MPI_recv' " , what should i do to solve this error. ...

Programatically unzip an AES encrypted zip file on Windows

I need to be able to unzip some AES (WinZip) encrypted zip files from within some C/C++ code on Windows. Has anybody got a way to do this? I'm hoping for either some appropriate code or a DLL I can use (with an example usage). So far my searches have proved fruitless. The commonly prescribed InfoZip libraries do not support AES encrypt...

Find the subsequence with largest sum of elements in an array

Hi, I recently interviewed with a company and they asked me to write an algorithm that finds the subsequence with largest sum of elements in an array. The elements in the array can be negative. Is there a O(n) solution for it? Any good solutions are very much appreciated. ...

Unresolved inclusion: <conio.h>. Why?

While running a simple c program I receive an Unresolved inclusion: <conio.h> What am I missing? I am using eclipse on fedora 13. Please help me resolve this problem. If I am missing any file or haven't installed anything let me know. Also I am new to fedora. Guide me with proper steps please. Thanks in advance. ...

Help needed to complete my homework

My teacher gave me an assignment: Write a program to input retail price of a product. If a 6.5% discount is given to a customer, then find and print the selling price. Additional Details: I'm new to programming. I haven't learned any functions except printf() and Scanf(). Please write the program using only these functions. I have d...

How to get the amount of free virtual memory on Apple / Mac?

How do I get the amount of free virtual memory on Mac OSX? I'm speaking of total free virtual memory (or: free addresses) and also the biggest allocatable continous block of memory available for the current process. (Like e.g. on Windows returned by GlobalMemoryStatus (free mem) or querieable with a combination of GetSystemInfo / Virt...

What are the arguments to main() for?

Everytime I create a project (standard command line utility) with Xcode, my main function starts out looking like this: int main(int argc, const char * argv[]) What's all this in the parenthesis? Why use this rather than just int main()? ...

What is the most efficient way to get java buffer in native code under JNI?

Problem: My code native code (c/c++) is called via JNI. Once it's started it needs to get byte[] buffer from Java object several times per second for further heavy processing. Native code should request buffer when processing of previous buffer is completed. The orginal idea was to pass buffer via AF_INET socket to avoid JNI stuff, b...

This piece of C/Obj-C code puzzles me

I've this simple method to shift element in an array. void queuePut(uint32_t val, uint32_t *q, int qlen) { for (int i=qlen; i>0; i--) { q[i] = q[i-1]; } q[0] = val; } In my class header i defined a struct @interface MyClass : NSObject { struct { uint32_t cookie[10]; uint32_t value[10]; } qu...

How to read reply from socket in c?

I'm trying to write a TCP client that does the following things: 1. Establish TCP connection to webserver 2. Accept GET request command from user's console 3. Client should get a reply back from webserver after each GET request. I'm having a difficult time for the 3rd condition. I did not receive any response back from the webserver. ...