i made a recursive function to find the prime factors of a number but it has a bug which makes turbo c quit. please help
#include<stdio.h>
#include<conio.h>
int prime(int num);
int primefactor(int num,int i);
void main(void)
{
int num;
printf("Enter a number whose prime factors are to be calculated:");
scanf("%d",&num);
...
For example, I have a cstring "E8 48 D8 FF FF 8B 0D" (including spaces) which needs to be converted into the equivalent unsigned char array {0xE8,0x48,0xD8,0xFF,0xFF,0x8B,0x0D}. What's an efficient way to do this? Thanks!
EDIT: I can't used the std library... so consider this a C question. I'm sorry!
...
Hi,
I have created a Foundation Tool in Xcode, and want to use some functions from the GraphicsMagick image manipulation library. The library has been compiled and installed on my computer using MacPorts. I added libGraphicsMagick.3.dylib and libGraphicsMagickWand.2.dylib to my project as external frameworks.
What other steps must I ta...
I have successfully gotten my low-level mouse hook code to work, but there are some behaviors I'm observing that I don't quite understand. Everything works fine if I spawn a thread which installs the mouse hook. When i no longer need it running, I let the thread get destroyed automatically as I exit the program, and I imagine I can easil...
I'm building a game and I'm looking for a good way to implement multiplayer. It is a sandbox game with Box2D physics. I was thinking of making it so the client only sends input to the server and receives which sprites to draw and where. Would this be a good idea? What might be ideal for a game with Physics like this?
Thanks
...
I'm trying to write a simple daemon in Linux, which will create a FIFO, then collect anything written to the FIFO and write that data to a file at a later time.
My expectations are that once my daemon has created the FIFO, I can do "echo text > /myfifo" repeatedly. When I'm done, I can do "echo quit > /myfifo" and my program will exit a...
Possible Duplicate:
#pragma once vs include guards?
When should I use #pragma once?
When should I use #ifndef HEADER_H_INCLUDED?
...
I only wanted to allow one instance of my C extension class to be made, so I wanted to include the singleton module.
void Init_mousetest() {
VALUE mouseclass = rb_define_class("MyMouse",rb_cObject);
rb_require("singleton");
VALUE singletonmodule = rb_const_get(rb_cObject,rb_intern("Singleton"));
rb_include_module(mousecl...
Which is an error-free way to get a http POST in CGI in C?
I'm currently using this. Is it ok? What if "CONTENT_LENGTH" is incorrect and is larger than stdin is; how will read behave then?
char *STDIN = NULL;
char *pointer = getenv("CONTENT_LENGTH");
if(pointer != NULL)
{
char charlength[5] = "";
strncat(charlength, pointer, 4...
Possible Duplicates:
function overloading in C
Does C support overloading ?
Can anyone explain if function overloading work in C?
I tried this and it didn't work:
#include <stdio.h>
int f(int val) {
printf("f int\n");
return 5;
}
int f(char *val) {
printf("f char *\n");
return 6;
}
int main() {
f(5);...
Is this code snippet well defined in ANSI C?
On my system (Linux x86_64) it seems to run just fine and print an address, but will it always be the case? E.g. the parameter might be passed via a register, and taking the address of that doesn't seem right.
#include <stdio.h>
void foo(int a)
{
printf("%p\n", &a);
}
int main(void)
{
...
Is there any book on programming FFMPEG encoding libs in c\c++?
I found one http://dranger.com/ffmpeg/
...
I bought MS C 5.0 after first getting QuickC 1.0 (I think because there was some limitation with QuickC that the full-blown C 5.0 didn't have, but I can't recall the details now). This was the summer of 1988 I believe. Anyway, there was an editor buried somewhere on the discs which wasn't the default editor. I can't remember the name of ...
How do I encode char string to Octet string in C? For example if have:
char *string = "245732473";
I need to encode this string to Octet string? How can i do this?
...
I created this question for the suggestion under this answer
...
i have made a program which converts numbers entered into a string into an integer.like atoi does.but its giving wrong output.
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<string.h>
void main(void)
{
static int sum;
int i,x,y,z;
char string[10];
printf("Enter a string:\n");
gets(string);
x=strlen(string);
for(i=0...
I have two shell scripts that I'd like to invoke from a C program. I would like shell variables set in the first script to be visible in the second. Here's what it would look like:
a.sh:
var=blah
<save vars>
b.sh:
<restore vars>
echo $var
The best I've come up with so far is a variant on "set > /tmp/vars" to save the variables and...
This works...
if ( tileType == "water" or
( otherObj and otherObj:GetType() == "IceBlock" )) then
self:SetNoClip( true )
else
self:SetNoClip( false )
end
-
These don't...
self:SetNoClip( tileType == "water" or
( otherObj and otherObj:GetType() == "IceBlock" ))
//----------------------------------------------------------
l...
I've defined 2 macros:
#define HCL_CLASS(TYPE) typedef struct TYPE { \
HCLUInt rc; \
void (*dealloc)(TYPE*);
#define HCL_CLASS_END(TYPE) } TYPE; \
TYPE * TYPE##Alloc() { TYPE *ptr = (TYPE *)malloc(sizeof(TYPE)); if (ptr != NULL) ptr->rc = 1; return ptr; }
The purpose of these macros...
When we define a character array as 'char name[10]', this indicate that the array 'name' can hold a string of length ten character. But in the program shown below the array name can hold more than ten characters. How is this possible?
//print the name of a person.
char name[10];
scanf("%s",name);
printf("%s",name);
Here if I e...