I use the below function to retrieve characters one by one from a FILE stream.
Now the text in that file will sometimes include places holders like !first_name! within the text. What's the best way to detect when such a place holder start and when it ends so that I can swap each character between !! with proper character from another sto...
I would like to be able to convert between std::vector and its underlying C array int* without explicitly copying the data.
Does std::vector provide access to the underlying C array? I am looking for something like this
vector<int> v (4,100)
int* pv = v.c_array();
EDIT:
Also, is it possible to do the converse, i.e. how would I ini...
Can anyone point me to the definition of strlen() in GCC? I've been grepping release 4.4.2 for about a half hour now (while Googling like crazy) and I can't seem to find where strlen() is actually implemented.
...
Where can I get a sample code for merge sort a link list?
...
What is the best algorithm to sort a link list [in C/C++]?
...
The classical unit testing is basically just putting x in and expecting y out, and automating that process. So it's good for testing anything that doesn't involve time. But then, most of the nontrivial bugs I've come across have had something to do with timing. Threads corrupt each others' data, or cause deadlocks. Nondeterministic behav...
Hi I'd like to read good tutorials on setjmp/longjmp in C. It'd be better if there're examples which are real rather than artificial.
Thanks.
...
Say you have the following ANSI C code that initializes a multi-dimensional array :
int main()
{
int i, m = 5, n = 20;
int **a = malloc(m * sizeof(int *));
//Initialize the arrays
for (i = 0; i < m; i++) {
a[i]=malloc(n * sizeof(int));
}
//...do something with arrays
//How do I fre...
All of us who still do some kind of network programming (TCP/UDP, DNS or Client/Server) in C repeatedly use some code snippets again and again.
We do use some standard libraries but then also we do write some code very often which is not there in one library.
Is there a collection of such code snippets that are used very often. If no...
$cc a.c
$./a.out < inpfilename
I want to print inpfilename on stdout.
How do I do that ?
Thanks for the help in advance...
...
I wonder if the naming convention used in C/C++ standard libraries has a name, or at least a cheat-sheet where I can lookup the rules. E.g.
push_back -- underscore used
setstate -- but not used here!
string::npos -- when to use abbreviations?
fprintf
...
Does the naming convention used in the C/C++ standard libraries have a sp...
Hi, I'm writing an application for Mac. I need some code which generates a hash from a string.
I need to create these hashes:
MD2
MD4
MD5
SHA-0
SHA-1
How can I do this?
Thanks.
...
Hi there,
I have some very specific questions related to emacs for building C applications:
1) How can I compile a file written in C/C++ using emacs.
2) How can I have something similar with MS Intellisense in emacs?
3) How can I add an C/C++ library to the compiler and emacs to know about it.
many thanks
...
Hi,
Because I would like to make some tests with the libpcap and a small C program, I am trying to pass a structure from main() to got_packet(). After reading the libpcap tutorial, I had found this:
The prototype for pcap_loop() is
below:
int pcap_loop(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
The last argume...
SO:
I'm having a bit of difficulty setting up a regex to match a URL using the regex.h library in c. I have a working IP regex that I was hoping to convert to match a simple string such as www.alphanumerictext12.com|edu|org. Something is wrong with my syntax in the regex definition itself.
Below is the working IPREGEX code and my a...
I am beginning work on an intelligent firewall but before I do that I need to understand clearly how a very basic firewall will work. Since me and my team is most comfortable in C we are going to use that.
Could someone give example of a very basic firewall written in C.
...
I am beginning work on a very basic HTTP proxy server written in C (Edit: something that just forwards my requests). At this point I am having difficulty in understanding how to proceed.
Any help would be beneficial.
...
Possible Duplicate:
reading a text file into an array in c
Hi,
I'm trying to read a file into a dynamic array.
Firstly I open the file using open() so I get the file descriptor
But then I don't know how can I allocate the memory using malloc to a dynamic array in order to do some data modification in the file from memory.
Than...
hi there
I'm into the learning stage of C and PHP. Until now I was using MS Visual Studio IDE for C/C++ applications and Notepad++ for PHP application.
Now I'm thinking to use same IDE for those languages and Eclipse seems to support both of them.
My questions are:
- Do you think is good to forgot about using MS Visual Studio for Ecl...
I'm a tad confused.
I am just getting started with OpenCV and its image data is pointed to by a char pointer. I can't quite work out how that works considering the actual data itself could be any number of data types, e.g. uint, float, double. As far as I knew, a pointer had to be of the same type as the pointer it represents.
It's p...