Ok, so I'm trying to create a program using a while loop to find the greatest common divisor of two numbers. This is what I came up with. However, from what I can tell, the program just seems to skip the loop entirely when I run it. (opers remains 0, divisor always comes back as equal to num1). Anyone out there that can help out a newbie...
Hello there,
i am trying to check, with plain c, whether the DST is set on a specific date and time. i have tested gmtime and localtime, but these functions only take care of the current system DST.
Thanks for your advice.
thomas
...
Writing my own toy shell, and have run into a bump trying to implement job control.
I am setting the process group of the child, both in the child and the parent with setpgid. My wait call is:
pid = waitpid(-pid, &status, 0)
However, waitpid returns -1 and perror says "No child process". However, it does seem to wait every time. ...
How do I fill an integer array with unique values (no duplicates) in C?
int vektor[10];
for (i = 0; i < 10; i++) {
vektor[i] = rand() % 100 + 1;
}
//No uniqueness here
...
I've noticed that the Linux kernel code uses bool, but I thought that bool was a C++ type. Is bool a standard C extension (e.g., ISO C90) or a GCC extension?
...
There is a scenario where an application tells a device on a network to get their IP address from the network router's DHCP server. If a DHCP server is not available, the device's behavior becomes erratic. Is there a method to procedurally detect if the network router supports DHCP? Or, is this something the device needs to do when at...
I am trying to read the value of a static variable in C like:
int variable = value;
The thing is that I only have the binary, and the code with a fake value (it is for a lecture, where we study security aspects of software development).
I have been trying to read the value using the GDB, and
(gdb)info variables
which just gives m...
Try to see which cast is faster (not necessary better): new c++ case or old fashion C style cast. Any ideas?
...
I have a daemon to write in C, that will need to handle 20-150K TCP connections simultaneously. They are long running connections, and rarely ever tear down. They have a very small amount of data (rarely exceeding MTU even.. it's a stimulus/response protocol) in transmit at any given time, but response times to them are critical. I'm ...
Consider an n-bit binary number in the following form:
bn−1bn−2bn−3...b0
Each bi is a single bit in the n-bit binary number. Each bi has one of two possible values: 0 or 1. An example of a 6-bit binary number is: 110011. Inside the computer, integers are represented as binary numbers. For example, the integer 43 can be repre...
I have a list of elements around 1000. Each element (objects that i read from the file, hence i can arrange them efficiently at the beginning) containing contains 4 variables. So now I am doing the following, which is very inefficient at grand scheme of things:
void func(double value1, double value2, double value3)
{
fooArr[100...
I'm a Linux user looking for a code beautifier which will take files containing C code and format them to specification. Specifically, I'm looking to:
Change all indentations to be 8 spaces
Format blocks of code consistently
Add line breaks consistently
It would be nice if it had both defaults and the ability to customize. I prefer f...
If I have an integer in c that represents the date how do I print out the actuall mm/dd/year?
64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC)
1183042181
what if I am on a 32 bit system, and have to read the integer in from a file?
C not C++
...
Ever since I realized many years ago, that this doesn't produce an error by default, (in gcc at least) I've always wondered why?
I understand that you can issue compiler flags to produce a warning, but shouldn't it always be an error? Why does it make sense for a non-void function not returning value to be valid?
An example as requeste...
I've done some research and I'm still struggling with the passwd structure.
http://www.opengroup.org/onlinepubs/000095399/basedefs/pwd.h.html
I need to obtain the user ID however I dont think I'm using understanding it at all.
int getpwuid_r(uid_t, struct passwd *, char *, size_t, struct passwd **);
This method call returns a point t...
When compiling and running my GLFW-based C program under Ubuntu (9.04), it fails when trying to open the window (it compiles fine, having installed the latest GLFW). I've tried varying resolutions, going as low as 300x300, and left the bit depths to zeros, hoping a default will catch on.
The relevant piece of code reads (directly snippe...
The negative implication of this is noted in the man page:
NOTES
Trying to take the absolute value of the most negative integer is
not
defined.
What's the reasoning behind this and what's the best recourse for a person who would like to avoid undefined behavior? Do I have to resort to something like:
unsigned...
I have a standard glut implementation. The display function redraws each object, but I need a constant update on certain values of each object. As it is, the only way I can think to do this is to spawn a thread to handle the updating. However, I can't use glutPostRedisplay() from a different thread to get glut to refresh the window. What...
Hi there,
I have to program a C/C++ application. I have windows and linux (ubuntu 9.04) in my machine, and can program in both of them (via gcc/code blocks/vim,etc). The problem is that the executable is going to be run in a Unix (not linux) machine (will have access to it in about 20 days).
My Team Leader doesn´t want all of the code...
what i mean is all the numbers _ _ _ _ _ _ _ are distinct and only values 2 to 9 can be entered. I've tried using array and loops but i just couldn't figure out the solution to display all the numbers.
examples 7-digit number among 2 to 9 are:
234567
234568
234569
324567
324568
324569
notice the none of the numbers in those values are...