프로그래밍 QnA

jee89의 이미지

기초 질문입니다.

#include <stdio.h>

typedef struct _ts {
char name[20];
int key;
} st_list_t ;

st_list_t *headp , *lastp;

int main()
{
if ( headp == lastp == NULL )
fprintf( stderr , "all Null Pointer\n" );
else
fprintf( stderr , "something wrong\n" );
}

이상을 실행하면
all Null Pointer 이 아니라
something wrong이 나옵니다.
headp , lastp가 전역외부변수이므로 0값을 가지므로
all Null Pointer가 찍혀야 맞지 않나요?

shean0의 이미지

[메모리 누수 문제]

안녕하세요..
메모리 누수문제 (malloc & free )때문에 질문을 드립니다.
지금까지.제가 짜면서..메모리 누수현상(다운...core..)을 가끔 경험한 적이 있습니다.

그런데.이런 것을 발견할때는 저는 코딩을 보고..고치고..그랬는데..
어떤 오류가 일어났을 때..이것이 free를 안해서 일어난.메모리 누수인지..어떻게 알수 있을까요??

분명이 malloc을 하면 free를 해야 하지만...프로그램을 짜다보니...
다른 사람의 소스도 봐야하구........그런 상황에서.. 메모리 누수를 알아채시는

ninakhlee의 이미지

정적라이브러리 포함시 에러..좀 봐주세요

gcc -o -I/home/test main main.o -ltest -lbind -L/home/test/lib
collect2: ld terminated with signal 11 [Segmentation fault]

make시 정적 라이브러를 포함하는 부분인데요.
위와 같은 에러가 발생합니다..
어디를 고쳐야 될지..
원래 소스에서 에러가 있어서 그런건가요?
/home/test/lib에 libtest, libbind는 다 들어있거든요..

^^*

jee89의 이미지

스레드에서 spurious wake up

pthread_cond_signal에 의해 sleep하던 스레드가
pthread_cond_wait에서 리턴할경우
spurious wake up때문에
반드시
while ( 조건 )
pthread_cond_wait( )
형태를 취한다고 하던데요.
spurious wake up는 어떤경우인지요?

sorrel의 이미지

gdb한 결과입니다. 원인이 뭘까요?

:roll: 안녕하세요. 제가 짠 소켓통신 하는 프로그램이 Segmentation fault를 내고 죽어서 아래와 같이 해봤습니다. Segmentation fault 의 원인이 오라클과 관련된 건가요? 답변 부탁드립니다. :D
[sorrel]$ gdb mp_server core
GNU gdb 19991004
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.

miso의 이미지

Linux에서는 TCP_NODELAY이 없나요?

/* disable nagle algorithm*/
if (setsockopt(so, IPPROTO_TCP, TCP_NODELAY, (char*)&tcp, sizeof(int))) {
printf("nagle algorithm error\n");
return FALSE;
}
에서 다음과 같은 에러가 나타나는 데요....
이유가 뭔지....

`TCP_NODELAY' undeclared (first use this function)
(Each undeclared identifier is reported only once
for each function it appears in.)

저는 unix가 아니라 linux거든요?
이것을 쓰려고 하는 이유는
socket 통신을 하는데 netstat 로 통신 상태를 확인하면...
TIME_WAIT 상태가 너무 오래 있거든요...
이것을 줄일 수 있는 방법이 없을까요?

ninakhlee의 이미지

정적 라이브러리 사용법 좀 알려주세요.

정적 라이브러리의 함수를 사용하고싶은데요.
헤더파일 include할때는 경로같은거 적어주지 않고 하고 싶거든요.

정적 라이브러리를 만들었는데요.
그 정적 라이브러리의 함수를 사용하려고 다음과 같이 했더니
아래와 같은 에러가 나요.

main.c:2:18: test.h: No such file or directory

main.c 내용은 다음과 같습니다.

#include <stdio.h>
#include "test.h"

int main()
{
    printf("Hello\n");
    sip_test();
    return 0;
}

김경태의 이미지

pointer에 대한 난해한 질문입니다.

1. 프로그램

[code:1]main()
{
int i, j;
int *a[3];
int (*b)[3];

b = ( int (*) [3] ) malloc(sizeof(int (*) [3] ));
printf("after malloc:(b) is %d, (b+1) is %d\n", b, b+1);

/* 0부터 2까지 b에 할당된 메모리에 i의 증가값을 대입후 print */
for(i = 0; i < 3; i++ )
{
*((char *)b + i*sizeof(int)) = i;
printf("b[%d]=%d\n", i, *((char *)b + i*sizeof(int)));

제리의 이미지

프로그래밍 질문입니다...도와주세요..

다음과 같은 프로그램이 있습니다. 파일 입출력 공부하고 있습니다.
argc의 용도가 무엇인지를 알고 싶습니다.

[code:1]#include <iostream.h>
#include <fstream.h>

/********************************************************
* count_one -- count # lines in a single file *
* *
* Returns the number of lines *
********************************************************/
int count_one(
istream &in_file // File to read
)
{
int count = 0; // Line counter

while (!in_file.eof()) {

appkr의 이미지

가끔 제목에 잘못된 HTML태그 가 글어가있는 경우

제목에 짝이 안맞는 태그가 들어가있는 경우엔 IE에서 제대로 못보여 주는 거 같은데-_-
(소스를 보면 다 받았지만 화면에는 아무것도 안나오는경우)
이거 어떻게 해결 할 수 없나요?
네스케이프에서는 잘 보이나?

페이지

프로그래밍 QnA 구독하기