Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OJT_PG
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
장 재용
OJT_PG
Commits
6caffd56
Commit
6caffd56
authored
3 years ago
by
choco5732
Browse files
Options
Downloads
Patches
Plain Diff
Initial commit
parents
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hello.c
+50
-0
50 additions, 0 deletions
hello.c
with
50 additions
and
0 deletions
hello.c
0 → 100644
+
50
−
0
View file @
6caffd56
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
int
main
(
void
)
{
// 파일 가져오기
FILE
*
pFile
=
fopen
(
"test2.txt"
,
"r"
);
if
(
pFile
==
NULL
){
return
0
;
}
int
count
=
0
;
fscanf
(
pFile
,
"%d"
,
&
count
);
// 자바 : call by refernece, C : call by value
if
(
count
==
0
){
return
0
;
}
// 텍스트의 값을 출력함 그 출력한 값을 다시 save 배열에 저장
int
save
[
count
+
1
];
// 이 배열 자체를 해시로 생각할 수 있어요
memset
(
save
,
0
,
sizeof
(
save
));
//memset : 지정한 값으로 배열을 한번에 초기화 해줌
int
i
=
0
;
int
num
=
0
;
int
check
=
0
;
int
save2
=
0
;
// 1 1 2 3 4 5 1293812903810293218093
save
[
1
]
=
1
;
save
[
2
]
=
0
;
// 텍스트 파일의 값을 save배열에 저장
for
(
i
=
0
;
i
<
count
;
i
++
){
fscanf
(
pFile
,
"%d"
,
&
num
);
// 입력 받은 num이 키인거죠
if
(
save
[
num
]
!=
NULL
){
check
=
1
;
break
;
}
save
[
num
]
=
num
;
}
if
(
check
==
1
){
printf
(
"Incorrect.
\n
"
);
}
else
printf
(
"Correct
\n
"
);
fclose
(
pFile
);
// 파일 닫아줌으로써 쓰기 즉 저장이 됨 (중요)
return
0
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment