Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
Tags
- 개인프로젝트
- SNS
- 코딩테스트
- java
- C++
- 프로그래밍
- frontend
- 모의 주식
- java정리
- 사물인터넷
- 자바정리
- 이웃한 칸
- Reflex
- 백준
- Python
- 자바독학
- Project
- 개발
- 빅데이터
- 코딩
- 코테
- 코딩독학
- 코스닥
- 주가예측
- 개발자
- 프로그램
- backend
- 프로그래머스
- 풀스택프레임워크
- 자바
Archives
- Today
- Total
Creative Code
main.c(serial함수) 본문
※main.c파일
#include <stdio.h>
#include "serial.h"
int main(void)
{
for (int i = 1; i<=10; i++){
int serialNumber = getSerialNumber();
printf("BATTERY_ALPHA_%010d\n",serialNumber);
}
for (int i = 1; i<=5; i++){
int serialNumber = getSerialNumber();
printf("BATTERY_ALPHA_%010d\n",serialNumber);
}
return 0;
}
※serial.h 파일
#ifndef SERIAL_H
#define SERIAL_H
int getSerialNumber(void);
#endif
※serial.c 파일
int getSerialNumber(void)
{
static int count = 1; // 전역변수로 int count =1;을 써도 되지만
// 전역변수를 사용하는 함수가 1개일 때는 함수안에
// static int count = 1;로 지역변수로 만들어줘도 된다.
return count++;
}
'C Programming' 카테고리의 다른 글
main.c(date) (0) | 2023.08.04 |
---|---|
main.c(구조체) (0) | 2023.08.04 |
main.c(rand함수) (0) | 2023.08.04 |
main.c(함수 선언) (0) | 2023.08.04 |
main.c (랜덤함수 라이브러리 생성) (0) | 2023.08.04 |