I am trying to open a text file with C++ in Mac OS X but I always get a Bus error.
I do not care where to put the file. I just need to read it. Am I writing its address wrong? or that Bus Error has another reason?
FILE *dic;
dic = fopen("DICT","rb");
dic = fopen("./DICT","rb");
dic = fopen("~/DICT","rb");
dic = fopen("~//DICT","rb")...
i have a char buffer[100] and i'm trying to use gdb to read the contents out of it at various stages of runtime.
i use p buffer and i get
"/*\000\000\000\000\000\000????X?o\000\025\202\004\b", '\0' <repeats 12 times>, ".N=?", '\0' <repeats 24 times>, "`\203\004\b\000\000\000\000L\227\004\bX????\202\004\b?\017\204\000\f?\203\000\210???...
First off, this is NOT a duplicate of: http://stackoverflow.com/questions/1911053/turn-a-c-string-with-null-bytes-into-a-char-array , because the given answer doesn't work when the char *'s are Unicode.
I think the problem is that because I am trying to use UTF-8 encoded char *'s instead of ASCII char *'s, and the length of each charact...
Is there any way to run the gcc preprocessor, but only for user-defined macros? I have a few one-liners and some #ifdef etc... conditionals, and I want to see what my code looks like when just those are expanded. As it is, the includes get expanded, my fprintf(stderr)s turn into fprintf(((__getreeent())->_stderr), etc...
...
Imagine I have a csv with and each value is an integer. so the first value is the INTEGER 100.
I want fscanf() to read this line, and either tell me it's an integer ONLY, or not. So, it would pass 100 but fail on 100t. What i've been trying to get work is "%d," where the comma is the delimiter of my CSV. so the whole function is
fscan...
Hey, I'm really struggling with this one. I'am trying to port a small piece of someone else's code to Python and this is what I have:
typedef struct
{
uint8_t Y[LUMA_HEIGHT][LUMA_WIDTH];
uint8_t Cb[CHROMA_HEIGHT][CHROMA_WIDTH];
uint8_t Cr[CHROMA_HEIGHT][CHROMA_WIDTH];
} __attribute__((__packed__)) frame_t;
frame_t frame;
while ...
The two programs below get n integers from file and calculates the sum of ath to bth integers q(number of question) times. I think the upper program has worse time complexity than the lower, but I'm having problems calculating the time complexity of these two algorithms.
[input sample]
5 3
5 4 3 2 1
2 3
3 4
2 4
[output sample]
7
5
9
...
Where can I find such programs? I think yacc and lex are this kind of programs? I'd like to see example codes especially in C language.
...
Hi, If I have a global static variable x like in this code
#include <stdio.h>
#include <stdio.h>
static int x;
int main(void)
{
DO SOMETHING WITH x HERE
x++;
}
What will be difference if I opted to initialize x to a value first say as in
static int x = 0;
before entering "main"?
In my first case where I didn't ass...
HI
I am writing a part of a server which should dispatch some other child processes.
Because I want to wait on some of the processes, and dispatch others without waiting for completion, I use double fork for the second kind of processes (thus avoiding the zombie processes).
Problem is, my server holds a lot of memory, so forking takes a ...
Does anyone have any suggestions for a good cross platform input library?
I'd like to get:
* at least keyboard and mouse input
* on at least the big three operating systems
* Small/fast
* C or C++
* permissive licensing gpl2/mit/free/etc.
So far I've seen:
* OIS (used in Ogre) http://sourceforge.net/projects/wgois/
* SDL (used everyw...
I've recently decided to undertake an SMS project for sending and receiving SMS though a mobile.
The data is sent in PDU format - I am required to change ASCII characters to 7 bit GSM alphabet characters. To do this I've come across several examples, such as http://www.dreamfabric.com/sms/hello.html
This example shows Rightmost bits o...
Hi,
I am looking for HTTP parsing library for C/C++.
I have looked curl library, but it seems it is a http client library.
I am looking for a library which parses HTTP header (e.g. a way to
get the query string, get cookie, get request url, get Post Data)?
Thank you.
...
Hello all, complete newbie here,
I need to find a way to store 250 KB of plain text numbers inside my program's executable file.
Usually, I would put the data in a separate file and let the program read it while it is running, but that's not an option here. Instead, the program and the data need to be in one executable file.
I have ab...
I'm trying to develop a simple application that will read some files, targeted for Windows CE. For this I'm using Microsoft eMbedded Visual C++ 3. This program(that is for console) will be called like this:
/Storage Card/Test> coms file.cmss
As you can see, file.cmss is the first argument, but on my main I have a condition to show ...
I'm working on a program where I try to pass parameters by reference. I'm trying to pass a 2D int array and a 1D char array by reference.
Function prototype:
void foo (int* (&a)[2][2], char* (&b)[4])
Function call:
foo (a, b);
However, when I compile the code with -ansi and -Wall flags on gcc, I get the following errors:
foo.c: A...
The standard method to send data on a stream socket has always been to call send with a chunk of data to write, check the return value to see if all data was sent and then keep calling send again until the whole message has been accepted.
For example this is a simple example of a common scheme:
int send_all(int sock, unsigned char *bu...
Hi, I always thought that *&p = p = &*p in C. I tried this code:
#include <stdio.h>
#include <stdlib.h>
char a[] = "programming";
char *ap = &a[4];
int main(void)
{
printf("%x %x %x\n", ap, &*(ap), *&(ap)); /* line 13 */
printf("%x %x %x\n\n", ap+1, &*(ap+1), *&(ap+1)); /* line 14 */
}
The first printf line (line 13) gi...
Here's what i have so far...
I have yet to figure out how i'm going to handle the 11 / 1 situation with an ace, and when the player chooses an option for hit/stand, i get segfault.
HELP!!!
updated code
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#define DECKSIZE 52
#define VALUE 9
#define FACE 4
#def...
I'm an intermediate C developer, trying to get better. I want to make a very basic and lightweight HTTP server with its own scripting language.
Could I use something like Lua for scripting? If not, what?
I don't want to use CGI/FastCGI like Apache does for PHP in most cases, I want my server to natively support my scripting language.
...