c

reading from a file line by line.

I want to read a txt file line by line. I am getting the error"the device is not ready". I can't understand what the problem is? The code is as follows: #include<stdio.h> #include<stdlib.h> int main(int argc, char **argv) { char command[100]; char line[10]; FILE* fp = fopen("input.txt","r"); while (fgets(line, sizeof line, fp) ...

How to find out if a file or directory exists?

Hi. I am trying to make a simple program that handles files and directories, but I have two major problems: how can I check whether a file or directory exists or not, and how do I know if it is a file, directory, symbolic link, device, named pipe etc.? Mainly file and directories matter for now, but I'd like to know the others too. ...

Why do game companies look for only C/C++?

Most of the requirements for a game programming job I've looked at required good C/C++ skills. I agree, most game engines are written in C/C++. But aren't the engines USED in a scripting languages? Don't the companies need scripting programmers to actually code the game from the game engine? Why haven't I ever seen a company that requir...

Embed XUL backend in C

I need to write a standalone (not under XULRunner) c/c++ application (Windows OS) that uses XUL as its backend GUI library. If it is possible, can you give me a link to an example application ? I saw something about libXul, is it needed ? where can i find it ? TNX, Vertilka ...

libxml2 HTML parsing

I'm parsing HTML with libxml2, using XPath to find elements. Once I found the element I'm looking for, how can I get the HTML as a string from that element (keeping in mind that this element will have many child elements). Given a document: <html> <header> <title>Some document</title> </header <body> <p id="...

How much is 32 kB of compiled code

Hello, I am planning to use an Arduino programmable board. Those have quite limited flash memories ranging between 16 and 128 kB to store compiled C or C++ code. Are there ways to estimate how much (standard) code it will represent ? I suppose this is very vague, but I'm only looking for an order of magnitude. ...

permutations and combinations

I have a program which creates some combinations of strings like if i entered input abc it gives me output as bcs cab abc #include<stdio.h> #include<string.h> int main() { char str[15]; int i,j,n; printf("Enter a string"); scanf("%s",str); n=strlen(str); for(i=0;i<n;i++) { str[n]=str[0]; fo...

conditional `ctypedef` with Cython

I need access to the uint64_t typedef from stdint.h in some wrapper code that I'm writing and I can't figure out how to get it done. The problem is that from what I can tell from the docs, my ctypedef will have to take the form: ctypedef unsigned long uint64_t or ctypedef unsigned long long uint64_t depending on if WORDSIZE from bi...

Turning on linker flags with CMake

When generating VS2010 targets with CMake, I would like the /LTCG flag turned on (only for release + releasewithdebinfo if possible, but its okay if its on for debug builds). How do I modify the linker flags? add_definitions() doesn't work because that only modifies compiler flags. And yes, I have wrapped it in if(MSVC). How do I modify...

Counting unique words in a file? Good Linear Search alternative?

I'm using a naive approach to this problem, I'm putting the words in a linked list and just making a linear search into it. But it's taking too much time in large files. I was thinking in use a Binary Search Tree but I don't know if it works good with strings. Also heard of Skip Lists, didn't really learn it yet. And also I have to use...

Objective-C to plain c iPhone game performance improvements

I'm testing a 2D OpenGL ES based iPhone game on both the iPhone 3G and the iPhone 4. It runs great on the iPhone 4... and pretty well on the 3G. The game state is updated at 60 Hz... and the rendering is done at 60 fps. Would the following conversion from Objective-C to c improve the performance at all? // current Objective-C functio...

Calling C DLL from Visual Basic 6: Double data type not working

I'm passing a simple user-defined type (UDT) from Visual Basic 6 to a C DLL. It works fine, except for the double data type, which shows up as 0. C DLL: #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <stdio.h> typedef struct _UserDefinedType { signed int Integer; unsigned char Byte; float Float...

hexadecimal value of ip into standard format

is there any function in linux to display the value 7d162f7d in the format 125.22.47.125 ie convert the hexadecimal ip address in its standard ip format ...

How can i get the numerical value (convert it to int) from a string?

I only see strings with only numbers. this is my string. SMUL 9 A B How can I get the number 9 as int type. Other possible string may be: SMUL 13 A B SMUL 43 100 21 ...

What is the difference between C & C# on the basis of OOP concepts?

What is the difference between C & C# on the basis of OOP concepts? ...

Microcontroller Serial Command Interpreter in C/C++; Ways to do it;

I'd like to interpret a command string, recieved by a microcontroller (PIC16f877A if that makes any difference) via serial. The strings have a pretty simple and straight-foward formatting: $AABBCCDDEE (5 "blocks" of 2 chracters+'$' for 11 characters in total) where: $AA= the actual name of the command (could be letters, numbers, both; m...

which one to choose for future , c++ or python2.x/3.x

since last four years i had been coding in c/c++, but those lenthy programs made me sick of them. then i got to know about python, and i have learned the basics. python seams to be more flexible and powerful than c++... But i want to know is python realy better than c++? if yes/no in what ways , please explain. since i am a student ,...

Gtk conversation effect

Hi, I was using some gnome applications like empathy and gwibber, and was wondering how to create a "conversation" effect in my own gtk application. E.g. http://www.ubuntu.com.cn/files/1004features/01.jpg (off google, not my site) Thanks ...

How to get the Start Timecode (SMPTE) of a Quicktime-Movie?

I'm working on Windows with the Quicktime-API and I wonder, how to get the start timecode (SMPTE) of a movie file? Can someone post a link or an example how to do that? ...

How can I split strings into different types (int for numerical values and char for letters)?

For example, I have this string: SMUL 9 A B? How can I get 9 (int type) A (char) and B (char). Possible string may be SMUL 12 A C, so it means their positions in the string is not constant. Further explanation: this is a string inputted by a user for my matrix calculator program. Inputting SMUL "scalar" "matrix-1" "matrix-2" means that ...