For the following C code (for swapping two numbers) I am getting the "conflicting types" error for swap function.
#include <stdio.h>
#include <stdlib.h>
void main()
{
int a,b;
printf("enter the numbers to be swapped");
scanf("%d%d",&a,&b);
printf("before swap");
printf("a=%d,b=%d",a,b);
swap(&a,&b,sizeof(i...
Can any body tell how to write a multiplication function (in C) using recursion?
...
I have a list in which i want to be able to put different types. I have a function that returns the current value at index:
void *list_index(const List * list, int index) {
assert(index < list->size);
return list->data[index];
}
In the array there are multiple types, for example:
typedef struct structA { List *x; char *y; Lis...
I am working on Ubuntu. How can I get MAC address of my machine or an interface say eth0 using C program.
...
After writing the following program, it does not appear to pass arguments to the called application. While researching _spawnv and what it can do, _execvp was found as what appeared to be a suitable alternative. Does anyone see the problem in the source code and know what needs to be done to fix it?
#include <stdio.h>
#include <stdlib.h...
I'm writing an iPhone app that's a mixture of Objective-C and C. I have 32-bit integer flags throughout my code that take on only two distinct values: 0 and 1. I'd like to use a data type that's smaller than 32 bits.
Is there a type that's only one bit? What is the size of "BOOL" in Objective-C?
One solution I've considered is usi...
I'm looking at a strcpy example where they increase the value of a pointer, and assign it in 1 line, like this:
*ptrA++ = *ptrB++;
I know that the value where the pointer is pointing to in the char array is increased, and the contents is copied.
does c do something like
*ptrA = *ptrB;
ptrA++;
ptrB++;
in the background ?
...
On Windows, you can go to "Run," type in "cmd," press enter, and start up "C:\Windows\system32\cmd.exe" rather easily. The same is true for "python" or "pythonw" (though nothing pops up in the second example). If all you know is that you want to execute "python" or "pythonw" and that it is on the PATH, what is the simplest way in C to fi...
I have a struct member that holds lots of string elements. What I want is to iterate the whole member of the struct and count only different elements (diff last names).
struct log {
char *last;
};
...
struct log *l
l->last = last_name; // loading *last member with data coming from last_name var
...
What would be a good way to com...
Hi, I'm trying to implement a fuzzy logic membership function in C for a hobby robotics project but I'm not quite sure how to start.
I have inputs about objects near a point, such as distance or which directions are clear/obstructed, and I want to map how strongly these inputs belong to sets like very near, near, far, very far. Does ...
I have a bitmap image that I am parsing and I need to be able to open the file and store the first unsigned short.
I tried to accomplish this using FILE and fscanf() but fscanf() always fails and returns 0 (number of items successfully read).
FILE *pFile = fopen ( fileName->c_str() , "r" );
if ( pFile == NULL )
{
cerr << "couldn't...
I have created one notebook GTK+ widget, and I am trying to set callbacks on some events as follows:
m_notebook = gtk_notebook_new();
g_signal_connect( GTK_OBJECT(m_notebook), "move-focus-out", G_CALLBACK( on_notebook_move_focus_out ), NULL );
g_signal_connect( GTK_OBJECT(m_notebook), "focus-tab", G_CALLBACK( on_notebook_focus_tab ), NU...
C\C++ open source PCM to Mp3 convertor/encoder?
What do I need
Open Source Libs/wrappers for encoding/decoding.
Tutorials and blog articles on How to do it, about etc.
...
How to write mp3 frames (not full mp3 files with ID3 etc) from PCM data?
I have something like PCM data (for ex 100mb) I want to create an array of mp3 frames from that data. How to perform such operation? (for ex with lame or any other opensource encoder)
What do I need:
Open Source Libs for encoding.
Tutorials and blog articles on ...
Hoe do you get to see the last print, in other words what to put in for EOF, I checked the defines and it says EOF is -1.
And if you Ctrl-D you won't see nothing?
#include <stdio.h>
int main() {
int c;
while((c = getchar() != EOF)) {
printf("%d\n", c);
}
printf("%d - at EOF\n", c);
}
...
I was stepping through some C/CUDA code in the debugger, something like:
for(uint i = threadIdx.x; i < 8379; i+=256)
sum += d_PartialHistograms[blockIdx.x + i * HISTOGRAM64_BIN_COUNT];
And I was utterly confused because the debugger was passing by it in one step, although the output was correct. I realised that when I put curly ...
Given the following code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a[1];
int * b = malloc(sizeof(int));
/* 1 */
scanf("%d", &a);
printf("%d\n", a[0]);
/* 2 */
scanf("%d", &b);
printf("%d\n", b[0]);
return 0;
}
the following warnings are obtained when it is compiled (i686-apple-d...
In the following statement :
system("%TESTCASES_PATH%SIP\\test.bat");
the %TESTCASES_PATH% gets resolved to "C:\Program Files..." .
As such the result of calling the system is :
"'C:\Program' is not recognized as an internal or external command.."
'C:\Program' is thought as a executable..
How to overcome the above issue?
EDIT: T...
I am trying to get my feet wet with JNI because I have an application in C that needs to access a single Java library function (no C-equivalent library). I've written a very simple test program to load a Java VM from C and call a static function and get the return value.
Unfortunately, I am unable to get the class to properly load. Al...
Whenever I run this code, I get a same result.
Program
#include<stdlib.h>
int main(int agrc, const char *argv[]) {
int i = rand();
printf("%d\n",i);
for(i=0;i<10;i++) {
printf("%d\n",rand());
}
}
Result:
41
18467
6334
26500
19169
15724
11478
29358
26962
24464
5705
I ran this on mingw. Actually I am learning Objective-C
Ple...