If I'm writing a library in C that includes a Python interface, is it OK to just write unit tests for the functions, etc in the Python interface? Assuming the Python interface is complete, it should imply the C code works.
Mostly I'm being lazy in that the Python unit test thing takes almost zero effort to use.
thanks,
-nick
...
I have made a program in graphics but when ever i enter any value in the graph it reaches its peak
#include <graphics.h>
#include <dos.h>
#include <graphics.h>
#include <conio.h>
#define LEFT 5
#define BOT 300
#define BWIDTH 10
#define TOPFLAG 1
#define BDEPTH 4
#define SEPARATION 12
#define SPACE 15
#define N 10
#define TOP 5
#define ...
I am trying to wrap a DLL, using its header file, through SWIG. I got a syntax error while processing my interface .i file using SWIG. After tracking down what was the offending line (line number of the printed by SWIG error message did not match the true offending line), I found that the minimum non-processable SWIG interface file is:
...
Hi there
Im working on a sparetime project, making some server code to an Arduino Duemilanove, but before I test this code on the controller I am testing it on my own machine (An OS X based macbook). I am using ints some places, and I am worried that this will bring up strange errors when code is compiled and run on the Arduino Duemilan...
I have a loop similar to this.
int total1, total2;
for (total1 = fsize(myfile);;) {
total2 = fsize(myfile);
...
...
total1 = total2;
}
What I would like to do is to convert this to a while loop and check for an extra condition before ending the loop.
I would like to do something like this:
while((total1 = fsize(myfi...
I have a very complicated program that is failing, and I've simplified it to this test set with a batch file and C program.
My C program uses ExitProcess to pass back the errorlevel to a batch file. Sometimes on Windows 7 (Microsoft Windows [Version 6.1.7600]), the errorlevel is not being interpreted correctly.
I think this should run ...
I am trying to write some code that works on both Linux and Win32. The most noticeable difference I find between them (in my code) is performance of fopen().
Following code takes 5 sec on my Ubuntu and the same code takes more than 100 sec on windows XP. I would like to make a note here that ubuntu is VM while XP is on a real machine.
...
Hi all.
I have a question about how is the correct way of manipulate the initialization of c strings
For example the next code, isn't always correct.
char *something;
something = "zzzzzzzzzzzzzzzzzz";
i test a little incrementing the number of zetas and effectively the program crash in like about two lines, so what is the real size li...
Hi my code is as follows
char name[100] ;
_getcwd(name, (size_t)sizeOfFileName);
strcat(name,"\\") ;
strcat(name, fileName) ;
char *value_str= NULL ;
file = fopen(name, "a+");
if(!file)
printf("bad file name") ;
for(i = 0; i<fileSize ; i++)
{
value_str = fp_to_str(ddata[i]) ;
strLength= strlen(value_str) ;
value_str[strLength+...
I'm fairly competent in a few scripting languages, but I'm finally forcing myself to learn raw C. I'm just playing around with some basic stuff (I/O right now). How can I allocate heap memory, store a string in the allocated memory, and then spit it back out out? This is what I have right now, how can I make it work correctly?
#inclu...
Hi,
I need to run a linux command such as "df" from my linux daemon to know free space,used space, total size of the parition and other info. I have options like calling system,exec,popen etc..
But as this each command spawn a new process , is this not possible to run the commands in the same process from which it is invoked?
And at...
Hi
Is there any link or material where I can learn more about the different error numbers in Linux ??
At present in man errno I get a single line for each error number but I would like to know the conditions or chances for which particular error occurs (A more detailed description in short words)
For e.g.
EADDRNOTAVAIL 99 /* Cannot ...
Hi.
I'm using Objective-C language. But I don't know how to use c with Objective-C.
Ex) This is Function method.
- ( ?? ) function{
unsigned int first = ..
unsigned int second = ..
unsigned int third = ..
int infoData = {first,second,third};
return infoData;
}
How to fill in parenthesis.
I don't use NSArray.
Please help me.
...
I want to use matrix palette API(Like OpenGLES1.1 extension API GL_OES_matrix_palette) on mac(XCode), linux(CDT) and windows(VC++).
But, those API was not able to be found.
And I do not want to use shader. (Only fixed functions)
...
What is the proper/preferred way to allocate memory in a C API?
I can see, at first, two options:
1) Let the caller do all the (outer) memory handling:
myStruct *s = malloc(sizeof(s));
myStruct_init(s);
myStruct_foo(s);
myStruct_destroy(s);
free(s);
The _init and _destroy functions are necessary since some more memory may be alloc...
Given log(a) and log(b), return log(a+b)
double log_sum(double log_a, double log_b){
double v;
if(log_a < log_b){
v=log_b+log(1+exp(log_a-log_b));
}
else{
v=log_a+log(1+exp(log_b-log_a));
}
return v;
}
I want to know what are the benefits of the above function?
...
I found the member variable name of m_rgNames in some source code. According to the naming convention, such as m_iNumber typed as int, rg could represent a type name. If this is case, what type did rg represent? Or else what's the meaning of rg in this variable name?
...
Hello,
I'm using FriendlyARM with linux 2.6.29 and compiling with ARM-Linux GCC
4.3.2
When trying to open a socket with PF_PACKET it fails with errno 97, Address
family not supported by protocol.
This is an example program that illustrates the problem -
#include <stdio.h>
#include <sys/socket.h>
#include <netpacket/packet.h>
#in...
#include <algorithm>
#include <stdio.h>
#include <iostream>
int intcomp(int *x,int *y) { return *x-*y;};
int a[10000];
int main(void){
int i; int n=0;
while (scanf("%d",&a[n])!=EOF)
n++;
qsort(a,n,sizeof(int),intcomp);
for (int i=0;i<n;i++)
printf("%d\n",a[i]);
return 0;
}
it is jus...
for example there is code
#include <algorithm>
#include <stdio.h>
#include <iostream>
int intcomp(int *x,int *y) { return *x-*y;};
int a[10000];
int main(void){
int i; int n=0;
while (scanf("%d",&a[n])!=EOF)
n++;
qsort(a,n,sizeof(int),intcomp);
for (int i=0;i<n;i++)
printf("%d\n",a[i]);
...