I' m trying to calculate the total sum of a line of command arguments entered in from the terminal. Thus far, I've gotten to the point where it will print out everything until the very last few digits. I have to make use of fork() to do all of the computation with my companion program. The main program is unable to do any computation for...
Hi guys - i was hopefully after some tips opposed to solutions as this is homework and i want to solve it myself
I am firstly very new to C. In fact i have never done any before, though i have previous java experience from modules at university.
I am trying to write a programme that converts a single integer in to binary. I am only al...
Can I mix extern and const, as extern const? If yes, does the const qualifier impose it's reign only within the scope it's declared in or should it exactly match the declaration of the translational unit it's declared in? I.e. can I declare say extern const int i; even when the actual i is not a const and vice versa?
...
Hi, all!
I have an array of data that represents PNG:
unsigned short systemFontTexture[] = {
...
0x5089,0x474E,0x0A0D,0x5089,0x474E,0x0A0D,0x5089,
0x474E,0x0A0D,0x5089,0x474E,0x474E,0x0A0D,0x5089,
0x474E,0x0A0D,0x5089,0x474E,0x474E,0x0A0D,0x5089,
...
}
Can I create PNG file using this data?
If yes, then HOW?
...
Hey,
I'm trying to define a macro which is suppose to take 2 string values and return them concatenated with a one space between them.
It seems I can use any character I want besides space.
for example:
#define conc(str1,str2) #str1 ## #str2
#define space_conc(str1,str2) conc(str1,-) ## #str2
space_conc(idan,oop);
space_conc woul...
#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
int main(int argc,char **argv)
{
int fd[2];
pid_t childpid;
pipe(fd);
childpid=fork();
if (childpid == -1)
{
perror("Error forking...");
exit(1);
}
if (childpid) /*parent proces*/ //grep .c
{
wait(&childpid); //...
I'm trying to allocate a block of memory and then copy data into that space. I made this simple program and it doesn't do what I expect it to do. Could someone please point out my faulty reasoning.
Thanks.
#include <stdio.h>
#include <stdlib.h>
void main(void)
{
int t1 = 11;
int t2 = 22;
int *bufptr;
bufptr = calloc(2, sizeof(int));
...
First, I have no experience doing this. But like the beginning of any good program, I have problem that I need to fix, so I'm willing to learn.
So many of you are probably already familiar with pdftk, the handy utility for handling various pdf-related tasks. So far as I can tell, most of these features are available in much newer, light...
Should we catch errors while parsing general purpose language as early as possible (in Lex) or where it is more convenient and give us more information (in Yacc)? How various languages solve this problem?
...
Why does this not work as expected?
int main()
{
unsigned char louise, peter;
printf("Age of Louise: ");
scanf("%u", &louise);
printf("Age of Peter: ");
scanf("%u", &peter);
printf("Louise: %u\n", louise);
printf("Peter: %u\n", peter);
return 0;
}
Outputs:
Age of Louise: 12
Age of Peter: 13
Louise:...
I am trying to print out binary number in c however the dilemma i have is that its printing out in the reverse order. I have defined a function to tell me how many bits there are, this way i can work from the last bit back
to get the nth bit i can use
(value >> totalNumberOfBits) & 1;
in a while loop i can run this until the totalNu...
I am working on a project where I have many constant strings formed by concatenation (numbers, etc.).
For example, I have a LOCATION macro that formats __FILE__ and __LINE__ into a string that I can use to know where I am in the code, when printing messages or errors:
#define _STR(x) # x
#define STR(x) _STR(x)
#define LOCATION _...
In my college days I read about the auto keyword and in the course of time I actually forgot what it is. It is defined as:
defines a local variable as having a
local lifetime
I never found it is being used anywhere, is it really used and if so then where is it used and in which cases?
...
This was asked to me in an interview!
i really got confused
How do I declare an array of N
pointers to functions returning
pointers to functions returning
pointers to characters
could anybody please help?
...
__FILE__ and __LINE__ are well known. There is a __func__ since C99.
#include <iostream>
struct Foo {
void Do(){ std::cout << __func__ << std::endl; }
};
int main()
{
std::cout << __func__ << std::endl;
Foo foo; foo.Do();
return 0;
}
will output
main
Do
Is there any macro / keyword that would output...
Hi.
I was looking through the web for a way to dynamically allocate space for 3d matrix, say of int type.
And i found many sites concerning 2d matrices, and this one
http://www.taranets.com/cgi/ts/1.37/ts.ws.pl?w=329;b=286
And there was this example as shown down.
I understood all of above examples but this concerning 3d i cannot. Is ...
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
double f;
printf ("What is the temperature in Fahrenheit?\n");
scanf ("%d", &f);
double x = (f-32)*(5/9);
printf ("%d degrees Fahrenheit \n",f);
printf ("%d degrees Celsius",x);
system("PAUSE");
return 0;
}
f seems to be printing address of variable f instead of the value...
Im confused with this question? Thank you in advance.
Programming in C under linux
...
I was wondering if there were any files in which I could set the -std=c99 flag, so that I would not have to set it for every compilation. I am using GCC 4.4 on Ubuntu.
...
Hi,
Is the ANTLR3 C Target Thread Safe?
Thx
...