I am writing a program that will need to measure time in minutes.
To be exact, it will wait 10 minutes, execute some code, wait 2 minutes, execute more code and repeat this 5 times (anyone guess what I'm trying to do?) and I am wondering how to do the breaks.
Thanks in advance!
Oh, and by the way, I'm on Mac.
...
I need to add the ability to take a screenshot of the entire screen, not just the current window. The following code produces a bmp file with the correct dimensions, but the image is completely black. What am I doing wrong?
void CaptureScreen(LPCTSTR lpszFilePathName)
{
BITMAPFILEHEADER bmfHeader;
BITMAPINFO ...
int num_arrays;
char *p[20];
char tempc;
int i=0;
do
{ p[i]=malloc(sizeof(int));
scanf("%s",p[i]);
tempc=*p[i];
++i;
}while(tempc=='x');
num_arrays=atoi(p[0]);
When i write num_arrays=atoi(..),gcc give me segmentation fault or memory
stack is exce...
Today in my interview, the interviewer asked: printf is a function and every function returns something; int, void, float, etc. Now what does printf return as it's a function?
...
Hello,
my task is to create dual program. At the beginning I start C program that calls throught C/C++ API of Python some Python method. The called method after that call a function that is created with SWIG. I show you my sample also with backtrace from gdb after I am given Segmentation fault.
main.c:
#include <Python.h>
#include <s...
I have the following chunk of a header file BKE_mesh.h:
/* Connectivity data */
typedef struct IndexNode {
struct IndexNode *next, *prev;
int index;
} IndexNode;
void create_vert_face_map(ListBase **map, IndexNode **mem, const struct MFace *mface,
const int totvert, const int totface);
void create_vert_edge_map(ListBas...
Hi,
I've a file that was written on windows with encoding WINDOWS-1256, and I need to write a C program that reads bytes from this file and write them back to a new file with UTF-8 encoding.
How to read a file with a specific encoding in C ??
...
I want to initialize a linked list with pointer arguments like so:
/*
* Initialize a linked list using variadic arguments
* Returns the number of structures initialized
*/
int init_structures(struct structure *first, ...)
{
struct structure *s;
unsigned int count = 0;
va_list va;
va_start(va, first);
for (s = f...
I have two simple microbenchmarks trying to measure thread- and process-switching overheads, but the process-switching overhead is turning out to be lower than that of thread-switching, which is unexpected. The setup: 1.8GHz Core 2 Duo, 2GB RAM, Linux 2.6.32-21-generic x86_64 (Ubuntu 10.04). I'm getting:
~2.1-2.4us per process switch
~...
I have a number of C source files(both .c and .h files). header files contains a number of functions. Out of those functions, only partially are used in a source .C file.Suppose a.h,b.h are header files and a.c and b.c are .c files. a.h is included in a.c. But only a number of functions those are in a. h are used and rest are not used...
Ok i have problem with my code for reading binary file...
First i will show you my writing code:
void book_saving(char *file_name, struct BOOK *current)
{
FILE *out;
BOOK buf;
out = fopen(file_name, "wb");
if(out != NULL)
{
printf_s("Writting to file...");
do
{
if(current != NUL...
I am still new at lists in C and i got a big problem...
First i wanna show you my code for inserting item to the list:
void input_books_info(int number_of_books, BOOK *current)
{
int i;
for(i = 0; i < number_of_books; i++)
{
while(current->next != NULL)
current = current->next;
current->next = (...
Hello,
Sorry I can't be specific with code, but the problems I am seeing are anomalous. Character string values seem to be getting changed depending on other, unrelated code. For example, the value of the argument that is passed around below will change merely depending on if I comment out one or two of the fprintf() calls! By the la...
In these days i'm playing with the C functions of atol(), atof() and atoi(), from a blog post i find a tutorial and applied:
here are my results:
void main()
char a[10],b[10];
puts("Enter the value of a");
gets(a);
puts("Enter the value of b");
gets(b);
printf("%s+%s=%ld and %s-%s=%ld",a,b,(atol(a)+atol(b)),a,b,(atol(a)-atol(b)));
ge...
Is there a way to get a menustrip instead of an HMENU when using the WinAPI? Like menus that .Net applications use? Because the HMENU just doesn't fit my color scheme, I need a darker menu.
Thanks
...
What's wrong with this?
#include <stdio.h>
void main(){
char *s="some text";
printf("%d",is_in(s,'t'));
}
int is_in(char *s, char c){
while(*s){
if(*s==c) return 1;
s++;
}
return 0;
}
I get the following compile time error with GCC:
test.c:9: error: conflicting types for ‘is_in’
test.c:9: note:...
int i=10;
printf("Address of i = %u",&i);
Output:
Address if i = 3220204848
Output on re-execution:
Address of i = 3216532594
I get a new address of i each time I execute the program. What does this signify?
...
I have three programs that need to be compiled at the same time, 2 written in C and 1 in java. I had all three working with the Makefile when they were in C, but then switched one of them to java... is there a way to compile all 3 at once with the same makefile?
Here is my current Makefile:
CC=gcc
JC=javac
JFLAGS= -g
CFLAGS= -Wall -...
I'm using WINARM Version 20060606 located here:
http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/#winarm
I want to create a simple static library as follows:
---- plus.h ------------
int plus(int x, int y);
---- plus.c ------------
#include "plus.h"
int plus(int x, int y)
{
return (x + y);
}
Then I want to sta...
hello,
I am developing a PC application that interacts with the Wii Remote. So far I have been using the wiiuse library, which has worked great.
However wiiuse does not support the MotionPlus extension.
I have heard of extensions to implement this by Dolphin and libogc but have not managed to locate this code.
Do you know of code that...