C is a general-purpose computer programming language used for operating systems, games and other high performance work and is clearly distinct from C++. It was developed in 1972 by Dennis Ritchie for use with the Unix operating system.
1
vote
1answer
23 views
how the following memcpy is beyond array in C?
I have the following code:
#define NUM_STUDENTS 20
#define TIME_STUDENTS 10
typedef struct
{
int name;
int age;
} Student;
typedef struct
{
int number;
int post;
} Contact;
typedef ...
0
votes
2answers
16 views
Catch a forced exit from terminal (x button on top OR ctrl+Z)
im making a chat in C using TCP connection between client and server.
Im running that on linux terminal.
First of all i run the server on one terminal, and then every client on another one.
...
1
vote
0answers
20 views
Forks & Shared Memory
If a process and its fork have different copies of the data, then why is their pointer the same?
In the example below, if count was shared between the parent and child processes, we would see count: ...
0
votes
3answers
17 views
The buffer '' is accessed out of bounds
During a check with the static code analysis tool cppcheck (http://sourceforge.net/apps/mediawiki/cppcheck/index.php?title=Main_Page) the tool discovered a severe error in the code:
#define ...
0
votes
1answer
44 views
using Strings in C/C++ — [ ] after LPCTSTR
came across this and was wondering what it does
LPCTSTR szmyLPCTSTR;
// doing _tcsncpy things with that string
//at the end then there is this line which i am not sure what it does
...
0
votes
2answers
16 views
how to covert dynamic linking to static linking
I have a program which use libevent library
when compile the program, the compiling command is like:
gcc -o myprogram mysource.c mysource.h -levent
so it is dynamic linking.
now I want to run ...
0
votes
3answers
43 views
Seg fault when using structure pointers to access struct members in C
What is wrong with my program, I get seg fault when I try to print the values.
My aim is assign some values in sample_function.
and in main function I want to copy the structure to another ...
1
vote
0answers
24 views
output to command line from windows gui program
I have a win32 gui based exe which is GDI based -
The program accepts command line arguments when it starts, and
I need a way to print out a message if the command line is incorrect.
At the moment, ...
0
votes
2answers
23 views
How would using scanf like gets work?
What would be the best way to imitate the functionality of gets with scanf?
Here is my current attempt
int main()
{
char cvalue[20]; //char array to store input string
int iloop=0; ...
5
votes
5answers
66 views
what is the purpose of putting a space in scanf like this scanf(“ %c”,&ch) in place of scanf(“%c”,&ch)?
what is the purpose of putting a space in scanf like this
scanf(" %c",&ch)
in place of
scanf("%c",&ch)?
Also what is input buffer in fflush(stdin)?
0
votes
1answer
30 views
When calling a C++ DLL from a C program it crashes when I try to access call parameter pointer in the DLL
I've written a C program that uses an array of pointers to functions. The
functions are both inside my program and in loadable DLL's. My problem comes
when I try to use a DLL that came from a C++ ...
0
votes
2answers
35 views
String in function parameter
int main()
{
char *x = "HelloWorld";
char y[] = "HelloWorld";
x[0] = 'Z';
//y[0] = 'M';
return 0;
}
In the above program, HelloWorld will be in read-only ...
1
vote
3answers
57 views
C: need a “sign” type
For my C computation, I need a sign type (an associated operator is acceptable) that can do the following:
type sign_t = -1 | 0 | 1
integer mult_sign(integer i, sign_t s)
{
switch (s) {
case ...
0
votes
0answers
5 views
defining custom symbols with microsoft 'link' command
I am trying to use the microsoft 'link' command to link some of my code, however I cant figure out how to define addresses for external symbols in the code. ex:
extern void mySymbol(void* data);
int ...
1
vote
2answers
33 views
Canonical name or IP address - socket, linux and C
How can I know if a string is the canonical name or the IP address?
Because if argv[1] is the IP address I do:
sscanf(argv[2],"%" SCNu16,&server_port);
inet_aton(argv[1],&server_address);
...