I would consider myself a fairly competent programmer with experience in Java and VB.net. My latest swim around the programming lake is having me modify a program written in C. (The program is Wireshark, an open source network analyzing tool.) I followed the instructions here http://www.wireshark.org/docs/wsdg_html_chunked/ChSetupWin32.h...
I meant to ask: why is the output of the following code 1 million?
If the program runs indefinitely but produces no output, write INFINITE LOOP as the answer to the question. All of the programs compile and run. They may or may not contain serious errors, however. You should assume that int is four bytes. You should assume that float ha...
I've just organized my code by using headers, but just as I've done this, I got a warning that turned into an error when linking.
I have a code(use of a function that is inside a header) in test.c that is like this:
#include "test1.h"
/* Some code */
main()
{
Testing();
}
And my test1.h header is like this:
void Testing();
void ...
Is there a new upcoming C Standard that supersedes C99? After all there's an unofficial C++0x coming out as per the source in Wikipedia here. For the sake of this question, let's call this C99 superset as C'y2k.01' to not confuse (as I was going to say C99++ which looks like the C++ counterpart.... but I digress)
If there isn't, what w...
Hello,
gcc 4.4.2
I was reading an article about scanf. I personally have never checked the return code of a scanf.
#include <stdio.h>
int main(void)
{
char buf[64];
if(1 == scanf("%63s", buf))
{
printf("Hello %s\n", buf);
}
else
{
fprintf(stderr, "Input error.\n");
}
return 0;
}
I am just wondering what othe...
man crypt
crypt(3) - Linux man page
char *crypt(const char *key, const char *salt);
Return Value
A pointer to the encrypted password is returned. On error, NULL is returned.
Since crypt is unknown unless key and salt is given, this should be a dynamically allocated memory, but valgrind doesn't agree..
Thanks.
...
Valgrind gives me the following leak summary on my code. However, I have freed all malloc'ed memory. Is this a bad thing, or is this normal? My program is in c.
==3513== LEAK SUMMARY:
==3513== definitely lost: 0 bytes in 0 blocks.
==3513== possibly lost: 0 bytes in 0 blocks.
==3513== still reachable: 568 ...
I wish to wrap an existing C (pure C that is. No C++) library into Python so that I can call it from Python scripts. Which approach among the various available (C Api, SWIG etc.) would be the most suitable?
...
Hi,
My c code uses 'memset' and 'close'.
And I have added:
#include <stdio.h>
#include <glib.h>
#include <stdlib.h>
But I still get these warnings:
main.c:259: warning: implicit declaration of function ‘memset’
main.c:259: warning: incompatible implicit declaration of built-in function ‘memset’
main.c:268: warning: implicit declarat...
While closing sqlite3 using sqlite3_close function it returns error code 5
5 - database file is busy. How to fix this issue.
...
Given an array all of whose elements are positive numbers, find the maximum sum of a subsequence with the constraint that no 2 numbers in the sequence should be adjacent in the array. So 3 2 7 10 should return 13 (sum of 3 and 10) or 3 2 5 10 7 should return 15 (sum of 3, 5 and 7).
I tried it using all possible allowed sums and then fin...
Now I get a 5-d matrix which M[j][i][l][ref][0]...
In this matrix, j,i belong to 0~4, while l=0. ref can vary from 0 to 4.
I just want to count the number according to ref's value.
For example,
if ref =0, I will do count0++,
if ref =1, count1++,
if ref =2, count2++
...
So, I do not care what is the value of M, I just want to know...
Hi,
In my project, where I adopted Aho-Corasick algorithm to do some message filter mode in the server side, message the server got is string of multibyte character. But after several tests I found the bottleneck is the conversion between mulitbyte string and unicode wstring. What I use now is the pair of mbstowcs_s and wcstombs_s, whic...
Hello, I'm trying to obtain my local (not the external) IP address using the getaddrinfo() function, but I saw the examples provided here, and they where too complex for my needs. Also saw other posts and most of them really wanted to get the external IP, not the local one.
Could anyone provide a link to a simple example (or a simple ex...
I know that .h file is supposed to have:
class declarations,
function prototypes,
and extern variables (for global variables)
But is there some significance of making it a .h file?
I tried renaming my .h file to a .c file and it still works.
We can name our file to be anything, but we choose to name it as a .h file.
Am I correct?
...
Hi all!
Banging my head for 1 hour, can't find the answer:
int *get_possible_moves(int **board, int *w, int *h, int *x, int *y) {
int movespossible=0;
int moveslist[2][8];
//4
if(x + 1 <= w-1 && y + 2 <= h - 1) {
if(board[*(int *)y + 2][*(int *)x + 1] == 0) {
moveslist[movespossible][0] = *(int *)x + 1;
breakpoint-> mo...
I'm trying to replace some thread communication with a custom queue, producer is currently using
PostThreadMessage, consumer is using WaitForSingleObject/PeekMessage.
http://www.justsoftwaresolutions.co.uk/threading/implementing-a-thread-safe-queue-using-condition-variables.html would be what I needed, but boost nor C++ is not an optio...
Program calculates sum of numbers from 1 to N..
Child process calculates sum of EVEN numbers.
Parent process calculates sum of odd numbers.
I want to get the return value of child process in parent process. How do i do that
#include<stdio.h>
#include<errno.h>
#include<unistd.h>
#include<stdlib.h>
#include<fcntl.h>
int main()
{
int ...
I want to jump from the middle of a switch statement, to the loop statement in the following code:
while (something = get_something())
{
switch (something)
{
case A:
case B:
break;
default:
// get another something and try again
continue;
}
// do something for a handled something
d...
The following code:
#include <stdio.h>
typedef union {
int n;
char *s;
} val_t;
int main(void) {
val_t v1,v2;
v1 = (val_t)"Hello World";
v2 = (val_t)10;
printf("%s %d\n", v1.s, v2.n);
return(1);
}
compiles and executes correctly with gcc. If one tries to cast a constant for which there's not a suitable field in t...