본문 바로가기
정리 전

21.01.29

by 오젼 2021. 1. 30.

warning: using the result of an assignment as a condition without parentheses

kldp.org/node/136328

 

c언어에서 이 경고 메세지는 뭔가요?? | KLDP

#include void change(char *a, char *b); int main() { char lt1[]="hello"; char lt2[15]; printf("hello\n"); change(lt1,lt2); printf("lt1 = %s\n", lt1); printf("lt2 = %s\n", lt2); return 0; } void change(char *a, char *b) { while(*b++ = *a++); } /*이렇게

kldp.org

"프로그래머가 "==가 아니고 =를 쓰려는 거 맞음ㅇㅇ"라고 gcc에게 알려주는 효과가 있나봅니다. 아마도 i=j==k 형태의 코드에서 경고를 하려는 의도가 더 크지 않았을까 싶기도..."

 

stncpy

stncpy는 문자열 끝에 꼭 널문자를 붙여주는 게 아니라고 한다. 그러니까 길이가 5인 문자열을 복사할 때 5만큼 복사하면 "hello\0"가 아니라 "hello" 이렇게만 복사됨. 주의하기. 대신 길이가 5일 문자열을 6만큼 복사했다면 "hello\n"이렇게 바꿔줌

"strncpy 함수는 복사시 destination 끝에 반드시 NULL 문자를 붙이는 것이 아니므로 사용에 주의를 해야 한다."

 

c++11 does not allow conversion from string literal to 'char *'

dhpark-blog.tistory.com/m/entry/C-ISO-C11-does-not-allow-conversion-from-string-literal-to-char?category=696387

 

[C++] ISO C++11 does not allow conversion from string literal to 'char *'

char *str = "Hello World!"; 위와 같은 구문을 그대로 컴파일하면 다음과 같은 오류가 발생한다. ISO C++11 does not allow conversion from string literal to 'char *' 위 오류를 방지하기 위해 명시적으로 형..

dhpark-blog.tistory.com

 

아스키(ASCII)코드


- 컴퓨터에서는 대부분 문자를 숫자로 변환해서 전송하는 방법을 사용한다.

- 약속한 정보가 서로 달라 문자를 제대로 전송할 수 없다는 문제점이 있다.

- 이런 문제점 때문에 문자를 숫자로 표현하기 위한 표준이 필요했는데 그 표준이 아스키(ASCII)코드이다.

  ASCII [American Standard Code for Information Interchange]

- 출력 불가능한 제어문자 33개, 출력 가능한 문자 95개로 이루어져있다.

  총 128개(8비트 중 7비트만 사용)의 코드로 구성된다. (1비트는 에러 표현을 위한 패리티 비트로 사용)

 

 

www.ionos.com/digitalguide/server/know-how/ascii-codes-overview-of-all-characters-on-the-ascii-table/

 

ASCII - American Standard Code for Information Interchange

ASCII characters: programs and internet content continue to rely on proven coding. This article will define ASCII and explain the standard.

www.ionos.com

 

'정리 전' 카테고리의 다른 글

21.02.03  (0) 2021.02.04
21.01.30  (0) 2021.01.31
21.01.27  (0) 2021.01.27
21.01.26  (0) 2021.01.26
21.01.25  (0) 2021.01.26

댓글