I have this program in C I wrote that reads a file line by line (each line has just one word), sorts the alphabets, and then displays the sorted word and the original word in each line.
#include<stdio.h>
int main()
{
char line[128];
int i=0;
int j;
int length;
while(fgets(line,sizeof line,stdin) != NULL)
{
char word[12...
Hi!
I have written C code for a TCP server to listen to one client at a time.. but I'm having difficulting finguring out how I can get the server to listen to multiple clients at one time.
Does any one know of a good tutorial or example explaining this?
Thanks!
...
I am attempting to create a const structure in C but can't seem to figure it out.
typedef struct sA{
char* fname;
char* lname;
} A;
To use as an Array:
A list[] = {{"david","smith"},{"john","smith"}};
However, if I have use a second struct:
typedef struct sB{
A inList[];
} B;
I want to define a const structure as:
B newList...
typedef struct _VIDEO_STREAM_CONFIG_CAPS
{
GUID guid;
ULONG VideoStandard;
SIZE InputSize;
SIZE MinCroppingSize;
SIZE MaxCroppingSize;
int CropGranularityX;
int CropGranularityY;
int CropAlignX;
int CropAlignY;
SIZE MinOutputSize;
SIZE MaxOutputSize;
int OutputGranularityX;
int OutputGranularityY;
int Stretch...
I am trying to write a PriorityQueue for a c project. The program is crashing when I try to dequeue items; however I think the issue is coming from the way I add the items, as If I try to access the first element in the list after adding the third element I get a crash as well.
Header file:
#ifndef PQUEUE_H_INCLUDED
#define PQUEUE_H_I...
I have been struggling to write a simple code to sort an array of char in C and been failing miserably. This is what I have so far:
int main()
{
char line[128];
char word[128];
int i=0;
int j;
int length;
while(fgets(line,sizeof line,stdin) != NULL)
{
length=0;
i=0;
while (line[i]!='\0')
i++;
lengt...
in how many languages /* ........... */ work as a comment? other than CSS
...
If you write int m[1000000]; inside the main function of C/C++, it will get a runtime error for stack overflow. Instead if you write vector<int> m; and then push_back 1000000 elements there, it will run fine.
I am very curious about why this is happening. They both are local memory, aren't they? Thanks in advance.
...
file contents:
apple
i have an apple
cookies
i have some cookies
I want to add print out these:
sorry:" appl" not found, nearest match is "apple" (missing a word)
<apple> " mean: I have an apple
and
sorry:" apples" not found, nearest is "apple" (add a word)
<apple> " mean: I have an apple
please go to the link>>>>>>>
Please...
Trying to understand what the pointer to function actually represent? Is it the address in the code segment where the function resides?
For ex: this piece of code:
#include <stdio.h>
void foo(void)
{
}
int main(void)
{
int a = 10;
printf("a's address: %p\n", &a);
printf("foo's address: %p\n", foo);
return 0;
}
... p...
Basically I have created a shell using standard POSIX commands, I want to be able to Implement Piping as well. Right now it handles commands correctly, and can do background processing with &. But I need to be able to pipe using | and >> as well.
For example something like this:
cat file1 file2 >> file3
cat file1 file2 | more
more file1 ...
Hi!
I don't know exactly how to word a search for this.. so I haven't had any luck finding anything.. :S
I need to implement a time delay in C.
for example I want to do some stuff, then wait say 1 minute, then continue on doing stuff.
Did that make sense? Can anyone help me out?
...
Lets say I have the function
void do_work (foo?);
The ? represents a 0 or a 1 which will be the value of variable
int bar = 0;
There are also the variables
int foo0 = 0;
int foo1 = 0;
I am trying to inject the value of one variable into the name of another variable so that the function gets the full name of either variable...
stdint.h in C99 provides many options for integer sizes, types and ranges - so many I don't know what ones to choose!
I know how to use size_t and ptrdiff_t when appropriate, and I use fixed size types for storage and transmission. My question concerns values that will only be stored in memory of the host machine.
For example, a struct...
Quoted from here:
CMediaType mymt;
AM_MEDIA_TYPE pmt = (AM_MEDIA_TYPE*)&mymt;
Why can a CMediaType object be cast to AM_MEDIA_TYPE?
Is such feature available in c?
UPDATE
Can someone answer it seriously what's the principle behind cast subclasses to their base classes, can I do it the other way around?
UPDATE2
AM_MEDIA_TYPE/C...
Possible Duplicate:
C# driver development?
Why do we use C for device driver development rather than C#?
...
I have called snprintf a few times consecutively with different arguments. I take the time needed for each snprintf. I found that the first call to snprintf takes the longest time. After that, the time needed to call the same function decreases until it converges. What is the reason for that? I have tried with other functions and also ex...
Given a 64 bit integer, where the last 52 bits to be evaluated and the leading 12 bits are to be ignored, what is the fastest way to loop every single combination of 7 bits on and all other bits off?
Example:
First permutation:
0[x57]1111111
Last permutation
00000000000011111110[x45]
Where 0[xn] means n off (zero) bits.
Speed is...
Hi there.
I'm writing a C program which takes n strings and concatenates them using strcat.
First I alloc'd the target string at sizeof(char)* the strlen of every string + 1 (for the null character). Then with a for I use strncat to create the final string.
At the and, I am appending the null character.
Everything goes fine, but somet...
Hallo,
I have some troubles understanding the python reference count.
What I want to do is return a tuple from c++ to python using the ctypes module.
C++:
PyObject* foo(...)
{
...
return Py_BuildValue("(s, s)", value1, value2);
}
Python:
pointer = c_foo(...) # c_foo loaded with ctypes
obj = cast(pointer, py_object).value
I'm...