c

How do I clear the contents of a file using c?

I'm writing some code so that at each iteration of a for loop it runs a functions which writes data into a file, like this: int main() { int i; /* Write data to file 100 times */ for(i = 0; i < 100; i++) writedata(); return 0; } void writedata() { /* Create file for displaying output */ FILE *data; data...

Producing a color map image using Python

I have a working program in C++ that generates data for a Mandelbrot Set. I am able to get the color map image of the Mandelbrot set using gnuplot. In order to save the image, I just take a screenshot which doesn't give a very accurate image. how I can use a Python script in order to produce and save the image. ...

Sparse Array in C! How accomplish it? Can I alloc only parts of an array?

Hi guys! The first question is: "How I do a simple sparse array in C (with one dimension only)?" {with my own hands, without libraries.} And the last one: "Can I allocate only parts of an array?" like *array; then use malloc to allocate some mem for this; so, We free the index that we don't want. Can I do it? Thanks so much! ...

C - equivalent of .NET Console.ReadLine

I need to accomplish the same behavior as .NET Console.ReadLine function provides. The program execution should continue when the user pushes enter key. The following code is not sufficient, as it requires additional input: printf ("Press Enter to continue"); scanf ("%s",str); Any suggestions? ...

What is the smallest Windows header I can #include to define DWORD?

I have a small header file of my own which declares a couple of functions, one of which has a return type of DWORD. I'm reluctant to drag in windows.h just to get the official definition of this type since that file is huge, and my header will be used in a number of source modules that don't otherwise need it. Of course, in practice I ...

making a gui editor

Hello, For my school project, I would like to build a gui that someone else can use to create a gui. Upon some research I saw lot of gui builders but didn't see anything along the lines of what I am looking for. But then I did find a tutorial using C# on here I rather create this gui editor for linux environment. Any suggestions t...

How can I get character-accurate identifier cross-reference for C99 code?

I maintain several modest-sized C programs, and I frequently have a use for fully accurate cross-reference information. Unlike "tags" or other approximations, such information is typically generated by a compiler that knows the full scoping rules of the C language and can provide accurate information accordingly. For example, here is a...

Why can I set an anonymous enum equal to another in C but not C++?

I have the following code snippet: enum { one } x; enum { two } y; x = y; That will compile in C, but in C++, I get the following error: test.c:6: error: cannot convert ‘main()::<anonymous enum>’ to ‘main()::<anonymous enum>’ in assignment Can someone explain to me why this is happening? I would prefer an answer with some specifics...

sd spi mode in C language

can i know how can we send data from spi to micro sd card in 'C' language ...

What are the main benefits of implementing a virtual machine as part of an application?

Several databases I've been looking at recently implement a virtual machine internally to perform the respective data reads and writes. For an example, check out this article on SQLite's virtual machine they call the 'VDBE'. I'm curious as to what the benefits of such an architecture are. I would assume performance is one but why would a...

Mime parser & composer for C language?

I am not going to use C++ or Java, but I can not find a MIME C library. Does somebody know? ...

Passing char * into fopen with C.

Hey there, I'm writing a program that passes data from a file into an array, but I'm having trouble with fopen (). It seems to work fine when I hardcode the file path into the parameters (eg fopen ("data/1.dat", "r");) but when I pass it as a pointer, it returns NULL. Note that line 142 will print "data/1.dat" if entered from command l...

Where can I find more information on creating a driver for a usb device in C / linux?

I know how about the capture part in wireshark. Parsing and figuring out the data shouldn't be a problem. Links to where I can get more information, tutorials or forums on how to target and receive from the device, or related content would be most helpful. ...

How to find the longest continuous subsequence whose reverse is also a subsequence

Suppose I have a sequence x1,x2,x3.....xn, and I want to find the longest continuous subsequence xi,xi+1,xi+2......xi+k, whose reverse is also a subsequence of the given sequence. And if there are multiple such subsequences, then I also have to find the smallest i. ex:- consider the sequences: abcdefgedcg here i=3 and k=2 aabcdddd he...

Program sometimes flagged as virus

Why is it that sometimes my program is flagged as a virus for some anti-virus software, when it's not? ...

string reverse without new array

hi can anybody tell me the error in this? #include<stdio.h> int main() { char a[]="abcdefgh"; int i=0; int n=strlen(a); char *first; char *second; char *c; *first=a[0]; *second=a[7]; for(i=0;i<=n/2;i++) { *c=*first; *first=*second; *second=*c; first...

how to use winsock to create an ftp for file transfer?

it is my third question for ftp file transfer between to machine where one machine has a shared folder and i have to access that folder from my machine using ansi-c or can use a third party lib for this purpose, as winsock i am doing this on windows platform the libs should be ansi-c complied that is a requirement.. i am stuck here ...

Monitoring CPU and disk utilization of a single program

How can I calculate CPU and disk utilization of another concurrent program? I.e. one program is running and other calculates the first's resource use. I'm using C and C++ and running under Windows XP. ...

Advisory locking interface for c in windows.

Hi all, I work on linux. Iam writing a locking interface. In linux the default locking is advisory locking where as in windows it is mandatory locking with LOCKFILE interface. I want a advisory locking interface in windows. ...

how to get rid off garbage in array of chars?

hi, I'm writing a C program but I keep having problems with my array of chars. I keep getting garbage when I print it using prinf. here is an example of what I get when I print it: char at t.symbol is Aôÿ¿ char at tabl[0].symbol is A char at tabl[1].symbol is a char at tabl[2].symbol is a char at tabl[3].symbol is d char at tabl[4]...