Here is a simple count word program, which i feel is very efficient. Is this the best way to count words in C, or are there any flaws in this program?
#include <stdio.h>
int CountWords(void);
main()
{
printf("count the words and enter string\n");
CountWords();
}
...
I just got an interesting problem to take care of, and I see no neat way to solve it.
I have two base data structures that represents a complex graph, declared something like this:
typedef struct _node_t node_t;
typedef struct _graph_t graph_t;
struct {
/* Data fields omitted */
node_t * pNextByLevel;
node_t * pNextByProx...
Hi all,
I am porting my application to windows from Linux. I am fairly new to the fine-art of porting application across platforms. As far as I know, Windows does not natively support POSIX threads implementation. Is this true? I have heard about some implementation of pthreads for windows (a wrapper or something), would it be better to ...
What's the difference between these two declarations, and is one preferred over the other?
typedef struct IOPORT {
GPIO_TypeDef* port;
u16 pin;
} IOPORT;
typedef struct {
GPIO_TypeDef* port;
u16 pin;
} IOPORT;
...
While investigating the D language, I came across GDC, a D Compiler for GCC. I downloaded the version for MinGW from here:
http://sourceforge.net/projects/dgcc/files/
Documentation was almost nonexistent, but it did say that most of the command line switches were the same as for the GCC compiler. However, that doesn't help me much, s...
I'm using NetBeans to develop some simple applications to solve puzzles. Upon launching one of these simple console applications, I'd like to get the input from a simple text file that I put together.
I recall mention of redirecting standard input and output. I looked up the syntax but I'm not sure on the proper way to tell NetBeans (o...
How can you (in C/C++) add text to a jpeg-file using libjpeg?
I do not mean by editing pixels, but by adding text to the meta-data (like the png_set_text() libpng library for png files).
...
As a part of a personal project, I am making an application level protocol (encapsulated in UDP) which is reliable.
For the implementation of reliability, I have to keep track of which packets i send, and which packets are received at the other receiver end. This is done with the help of a sliding window, and it also maintains the flow-...
I'm going to be making changes to my version of GEdit. I would also like to submit some of my code to the actual GEdit team (bug fixes and stuff like that). GEdit uses a standard to format code like so:
static void hello( GtkWidget *widget,
gpointer data )
{
g_print ("Hello World\n");
}
Which I forget (can't s...
I thought you could declare an array, and then later initilze it.
Like so
char* myArray[3];
//CODE INBETWEEN
myArray[3] = {
"blah",
"blah",
"blah"};
...
I'm trying to programatically get a list of installed fonts in C or Python. I need to be able to do this on OS X, does anyone know how?
...
Ok, I'm still new to using C sockets, but I was wondering if there is a way to extract the IP address adding running setsockopt? If you'll look at my code below, I have everything in my multicast sockets ready to send except for defining the variable mc_addr which is my IP address. Am I doing anything wrong that's real noticeable? If so,...
I'm using Linux Inotify to detect FS events on my program.
How could I be notified when a device is mounted on a monitored directory?
...
How do I achieve the following conversion from double to a string:
1.4324 => "1.43"
9.4000 => "9.4"
43.000 => "43"
ie I want to round to to decimal places but dont want any trailing zeros, ie i dont want
9.4 => "9.40" (wrong)
43.000 => "43.00" (wrong)
So this code which I have now doesn't work as it displays excess twos:
[NSString...
Hey,
I was wondering if it's possible to use C constructors in VC just as it is possible to use them in GCC.
The gcc way is quite straight using the attribute keyword, unfortunately VC doesn't seem to even know this keyword, as I'm not a Win32 programmer I wonder if there's some sort of equivalent keyword for such things.
Just to note -...
what is the proper way to do If statement with two variable in Xcode for Iphone
currently I have
if (minute >0) && (second == 0) {
minute = minute - 1;
second = 59;
}
...
The following code :
int *a;
*a = 5;
will most likely result in a segmentation fault and I know why.
The following code :
int a;
*a = 5;
won't even compile.
(gcc says : invalid type argument of unary *).
Now, a pointer is simply an integer, which is used
for storing an address.
So, why should it be a problem if I say :
*a = 5...
When I compile and run the following code :(using gcc on cygwin)
int *a = malloc(1024*1024*100*sizeof(int));
while(1)
;
The task manager in Windows XP shows
memory usage by this process as 2232K,
which according to me should have been around 400000K.
When I compile and run the following code :(using gcc on cygwin)
int *a = malloc(...
Is the sizeof(enum) == sizeof(int), always ?
Or is it compiler dependent?
Is it wrong to say, as complier are optimized for word lengths (memory alignment) ie y int is the word-size on a particular complier.Does it means that there is no processing penalty if i use enums, as they would be word aligned.
Is it not better if i put all th...
I have to transfer some values to be used as commands over the network, and I wish to make it as efficient and robust as possible, i.e. I need opinions on what to use for these commands, #defines or enums?
The range of commands shall not be more than 20 commands(lets say 40 with every defined response to the command), so according to mo...