Hi
I am playing with the printf and the idea to
write a my_printf(...) that calls the normal printf
and a sprintf that sends the result to a special function.
(I was thinking about sprintf since that behaves just like printf on most platforms).
My idea was to write a small macro that did this:
#define my_printf(X, Y...) do{ printf...
see this code
#define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))
int array[] = {23,34,12,17,204,99,16};
int main()
{
int d;
for(d=-1;d <= TOTAL_ELEMENTS-2;d++)
printf("%d\n",array[d+1]);
return 0;
}
now this loop won't run.
sizeof() would return an unsigned value so TOTAL_ELEM...
int main(void) {
char tmp, arr[100];
int i, k;
printf("Enter a string: ");
scanf_s("%s", arr);
for ( k = 0, i = (strlen(arr) - 1); k < (int) (strlen(arr) / 2); --i, ++k) {
tmp = arr[k];
arr[k] = arr[i];
arr[i] = tmp;
}
puts(arr);
return 0;
}
I know that there is so...
I was going to make an AIR application but I need to execute an external application and because of the security restrictions in Adobe AIR... I was thinking why not try and bypass it by writing some C code that does something like System("file to execute"); and then use Alchemy to change it into a swc and us that in my application... ...
Both operations create an empty file and return the filename but mkstemp leaves the file open in exclusive mode and gives you the handle. Is there a safety benefit to the C-function? Does this imply that there is a safety hole in the command-line version?
As an aside, it is interesting that there are several related functions in the C...
Been doing mostly Java and smattering of .NET for last five years and haven't written any significant C or C++ during that time. So have been away from that scene for a while.
If I want to write a C or C++ program today that does some multi-threading and is source code portable across Windows, Mac OS X, and Linux/Unix - is PThread a goo...
Not unlike a clap detector ("Clap on! clap clap Clap off! clap clap Clap on, clap off, the Clapper! clap clap ") I need to detect when a door closes. This is in a vehicle, which is easier than a room or household door:
Listen: http://ubasics.com/so/van_driver_door_closing.wav
Look:
It's sampling at 16bits 4khz, and I'd like to av...
I've coded a program in C that sends messages to the stdout using printf and I'm having trouble redirecting the output to a file (running from bash).
I've tried:
./program argument >> program.out
./program argument > program.out
./program >> program.out argument
./program > program.out argument
In each case, the file program.out is...
How can we extract the decimal part of a floating point number and to store the decimal part and the integer part into seperate two integer variables?
...
What is the purpose of anonymous { } blocks in C style languages (C, C++, C#)
Example -
void function()
{
{
int i = 0;
i = i + 1;
}
{
int k = 0;
k = k + 1;
}
}
Edit - Thanks for all of the excellent answers!
...
I would like to get my feet wet contributing to Gnome projects. I've downloaded svn sources of various projects and tried to explore the code but obtaining a working understanding of any of the projects, even the simpler ones like Eye of Gnome, seems intractable.
I admit, I am used to developing C/C++ in IDEs such as Eclipse CDT which...
1.
main()
{
if(-1<(unsigned char)1)
printf("-1 is less than (unsigned char)1:ANSI semantics");
else
printf("-1 NOT less than (unsigned char)1:K&R semantics");
}
2.
int array[] = {23,41,12,24,52,11};
#define TOTAL_ELEMENTS (sizeof(array)/sizeof(array[0]))
main()
{
int d = -1,x;
if(d<=TOTAL_ELEMENTS -2)
x =...
I am comfortable with C. but need to learn GObject and Glib for gstreamer. All i found on net is Gobject reference manual. Its good but looking for tutorial for Gobject/Glib as the main focus is on gstreamer.
So pls share any other resources to learn the glib and gobject.
...
Hi All,
I would like to know if there are any tools that can help me model C applications i.e. Functional programming.
E.g. I'm currently building a shared library.
But to communicate my design visually, I need something like UML. I would like to do this so that the person reviewing my design need not read through 100s of pages of funct...
I am very new to C and I have some problems learning about pointers. I experimented swapping and that's all what I can do with them :) I know that every variable has its own address in memory cells (this is what my lecturer told us) and every variable's value can be obtained by going to its associated address and then fetching the value ...
I've used strpbrk() occasionally while doing low-level string work in C, but I've never been able to figure out what it stands for. I've always pronounced it internally in my head as "stir p bark", but that's never quite felt right.
It doesn't have an etymology as obvious as any of the other string functions, e.g. strchr (string cha**r...
OK, info break lists the breakpoints, but not in a format that would work well with reusing them using the --command as in this question. Does gdb have a method for dumping them into a file acceptable for input again? Sometimes in a debugging session, it is necessary to restart gdb after building up a set of breakpoints for testing.
E...
I'm using C++ to understand how exactly pointers work. I have this piece of code using arrays, which I'm using just to understand how the equivalent works with pointers.
int main() {
int arr[10] = {1,2,3};
char arr2[10] = {'c','i','a','o','\0'};
cout << arr << endl;
cout << arr2 << endl;
}
However when I run th...
I'm a beginner C programmer, and I assumed that this would be the case, but would like some affirmation if possible.
If they are the same, why not just take one argument instead?
...
So I have some code that looks like this:
int a[10];
a = arrayGen(a,9);
and the arrayGen function looks like this:
int* arrayGen(int arrAddr[], int maxNum)
{
int counter=0;
while(arrAddr[counter] != '\0') {
arrAddr[counter] = gen(maxNum);
counter++;
}
return arrAddr;
}
Right now the compilier tells me "warning: passing argume...