I am embedding Lua into a C/C++ application. Is there any way to call a Lua function from C/C++ without executing the entire script first?
I've tried doing this:
//call lua script from C/C++ program
luaL_loadfile(L,"hello.lua");
//call lua function from C/C++ program
lua_getglobal(L,"bar");
lua_call(L,0,0);
But it gives me this:
...
I'm writing a 2D game using OpenGL. When I want to blit part of a texture as a sprite I use glTexCoord2f(u, v) to specify the UV co-ordinates, with u and v calculated like this:
GLfloat u = (GLfloat)xpos_in_texture/(GLfloat)width_of_texture;
GLfloat v = (GLfloat)ypos_in_texture/(GLfloat)height_of_texture;
This works perfectly most of ...
I want to convert WinMain's cmdLine argument to argc and argv so I can use the argument parsing function I wrote for console applications.
This would be trivial except that I want to support "quotes" too. For example:
test.exe test1 test2 "testing testing"
should be
argv[0] = "test.exe"; argv[1] = "test1"; argv[2] = "test2"; argv[3] ...
Where I work we build and distribute a library and a couple complex programs built on that library. All code is written in C and is available on most 'standard' systems like Windows, Linux, Aix, Solaris, Darwin.
I started in the QA department and while running tests recently I have been reminded several times that I need to remember ...
I'm using the old good Mixer API right now, but it does not work as expected on Windows Vista & 7 in the normal, not in XP compatibility mode. It mutes the sound for the current app only, but I need a global (hardware) mute. How to rearch the goal? Is there any way to code this w/o COM interfaces and strange calls, in pure C/C++?
...
I want to have a static array with arrays in it. I know you can make a normal array like this:
int test[] = {1,2,3,4};
But I want to do something like this (Xcode gives me a bunch of warnings and stuff):
int test[] = {{1,2}, {3,4}};
In python it would be:
arr = [[1,2], [3,4]];
What's the proper way to do this?
...
Is there any way to get the source code by using object file in C .
For example I have a source code simple.c
cc simple.c
Now I have a.out ( object file ) By this a.out whether can I get the source
code of simple.c
Thanks.
...
What is segmentation fault? Is it different in C and C++? How are segmentation fault and dangling pointer related?
...
I get this error (title of this question), when I am attempting to debug C/C++ programs using gdb with Netbeans IDE.
Does anyone know what this means, and how to get rid of the warning?
I am able to debug despite the warning, but I'd still like to make the warning go away.
Relevant details:
OS: Ubuntu 9.10
gdb: 7.0-ubuntu
Netbeans: ...
I don't want to write my own boot loader -- happy to use Grub.
I just want to implement pre-emptive multi threading, a basic file system, and virtual memory.
I want something that can run on top of qemu.
What's a good resource (book / tutorial) for accomplishing this goal?
Thanks!
...
I m looking for a faster implementation or good a approximation of functions provided by cmath.
I need to speed up the following functions
pow(x,y)
exp(z*pow(x,y))
where z<0. x is from (-1.0,1.0) and y is from (0.0, 5.0)
...
I have a dependancy library (libfcgi) that I compiled with g++ (GCC v4.4 MinGW) using the following calls:
g++ -Iinclude -c -O2 *.c
ar rcs ../libfcgi.a *.o
Now, my main project is built like so:
g++ -Idependancies\libfcgi\include -Ldependancies -O2 -lfcgi *.cpp
g++ apparently finds libfcgi.a, but yet it fails to link to the...
It does not work.
#include<stdio.h>
void bubble_sort(int m, int a[100000]);
void main()
{
int a[100000], i, m;
FILE * be;
be=fopen("be.txt","r");
// IMPORTANT! i pressed enter after last number in be.txt!!!
for (i=0; !(feof(be)); ++i)
fscanf(be,"%i", a+i);
m=i-1;
bubble_sort(m ,a);
fclose(be);
}
void bubble_sort(int m, in...
Hi,
I'm working on a client-server application written in C,
I want to broadcast a message to all the machines available in the network.
How can I do that using the usual socket system calls in C ?
Thank you!
...
hi all, my problem is in convert a char to string
i have to pass to strcat() a char to append to a string, how can i do?
thanks!
#include <stdio.h>
#include <string.h>
char *asd(char* in, char *out){
while(*in){
strcat(out, *in); // <-- err arg 2 makes pointer from integer without a cast
*in++;
}
return out;...
If you have an array in C, how can you find out how much of it is filled?
...
Is there a "proper" way of clearing a screen in C for a console application?
(Besides using:system("cls"))
...
I am trying to organise my UART library and prettify it a little bit by adding some #define s so I can customize it later without having to dig deeply into the code, but I can't seem to get the following bit of code working:
#define FOSC 8000000
#define BAUDRATE 9600
#define BRGVAL (FOSC/2)/(16*BAUDRATE)-1
void uart_init...
Hi all
I try to define a 64 bits width integer using C language on Ubnutu 9.10. 9223372036854775808 is 2^23
long long max=9223372036854775808
long max=9223372036854775808
When I compile it, the compiler gave the warning message:
binary.c:79:19: warning: integer constant is so large that it is unsigned
binary.c: In function ‘bitRever...
Hi,
I'm using the FNV hash as a hashing algorithm on my Hash Table implementation but I'm getting the warning in the question title on this line:
unsigned hash = 2166136261;
I don't understand why this is happening because when I do this:
printf("%u\n", UINT_MAX);
printf("2166136261\n");
I get this:
4294967295
2166136261
Which ...