Answering my own question, it seems that int64_t is the correct choice, as of C99. Second question still stands, though.
Type: Posts; User: pdc
Answering my own question, it seems that int64_t is the correct choice, as of C99. Second question still stands, though.
What's "best" type to use to guarantee a 64-bit quantity? I know it's implementation and platform dependent, but is their any sort of de facto standard? I've seen int64_t, __int64, int64...
Also,...
You want something like:
#include <stdio.h>
#include <unistd.h>
#define BUFSIZE 100
int main(void) {
char buf[BUFSIZE];
I'm aware of it, yeah, but it (thankfully!) seems pretty dead these days.
Sorry, yeah, Windows calls it _popen(). It has much the same behaviour, except read-write mode is "rw" and not "r+".
popen() is standard, I don't think socketpair() is available on Windows as it is on UNIX.
By all means, code in whatever style suits you best. Just remember that current styles have evolved because they generally prove to be most readable in the long-run, and that you're probably not...
AFAIK: popen() can create bidirectional pipes on OS X and BSD, but only unidirectional on Linux and Solaris.
Use popen(), defined in stdio.h. For example, for cross platform sockets ;):
#include <stdio.h>
#define BUFSIZE 100
int main(void) {
char buf[BUFSIZE];
FILE * f = popen("telnet...
All that code is valid C.
Tell us what part of it you can't understand, and someone might try to help.
In general, C style is not to indent braces. I.e., the above should be:
#include <stdio.h>
#include <conio.h>
int main()
{
char c;
long a = 0;
while (a != -1)
It should be:
struct node {
int x;
struct node *next;
};
The original version could be made valid with an appropriate typedef.
If you're willing to use Cygwin it is, at least:
http://mir.zyrianes.net/cygwin/release/ncurses/
That's great, exactly what I was looking for, thanks!
That doesn't work. As I said, representing them isn't the problem. Reresenting them as a string literal is. Can they be written as "<something>"?
PS, you should look at rewriting a lot of your code. For example, you have 11 lines of the form
freq[0] = freq[0] + 1;
These could be condensed to just one. Remember that an array subscript can...
Use atoi() and fgets(), both defined in stdio.h:
#include <stdio.h>
#define BUFSIZE 5
int main(int argc, char * * argv) {
char buf[BUFSIZE]; //max of five digits
printf("How many...
Yes, as of C99, but it's not a library. Just include <stdbool.h>.
#include <stdio.h>
#include <stdbool.h>
int main(int argc, char * * argv) {
bool b = getc(stdin) == 't' ? true : false;...
What memory you allocated? The struct only contains space for a pointer to a string, not the memory for the string itself. (It couldn't contain the memory for the string, not knowing how big it will...
Consider taking a look at curses, or ncurses, which is available for almost all UNIX-like OSs, and has a non-blocking getch() call:
#include <ncurses.h> /* ncurses.h includes...
When you store a string's value somewhere else, you either mean copying the whole sequence, or just copying the address of the start of the sequence. The latter seems simplest here.
In your case,...
I should probably add, since this is platform-dependent, that I'm using GCC on OS X and FreeBSD.
What's the best way of embedding UTF-8 (specifically UTF-8, not Unicode) literals in strings in C? You can, of course, do them as byte (char) sequences, but that makes it impossible to write
char...
Thanks, yeah, I just went with something similar myself in the end. It was always going to be an opportunistic hack, nothing Dijkstra would approve of :)
For debugging purposes, is there any way of programatically retrieving the symbolic name of a field in an enum, rather than just printing its numeric value? I'm pretty sure there's no way in ANSI C,...