fgets, fputs |
typedef struct student void ShowStudentInfo(Student *sptr);
for(i=0;i<3;i++) while(getchar() != '\n'); //enter이면 빠져나간다. 따라서 enter가 올때까지 읽어들여서 입력버퍼에 있는 값을 빼냄.. ShowStudentInfo(arr); void ShowStudentInfo(const Student *sptr) printf("\n"); |
|
|
#include<stdio.h> int main(void) { FILE * fp=fopen("c:\\project\\mystory.txt","wt"); if(fp==NULL) { puts("파일 오픈 실패!"); return -1; } fputs("#이름: 윤성우\n",fp); fputs("#주민번호: 900208-10122589\n",fp); fputs("#전화번호: 010-1111-2222\n",fp);
fclose(fp); return 0; } #include<stdio.h> int main(void) {
FILE * fp=fopen("c:\\project\\mystory.txt","at"); if(fp==NULL) { puts("파일 오픈 실패!"); return -1; }
fputs("#즐겨먹는 음식: 짬뽕, 탕수육\n",fp); fputs("#취미: 축구\n",fp);
fclose(fp);
return 0; } #include<stdio.h> int main(void) { char str[30]; int i=0; FILE * fp=fopen("c:\\project\\mystory.txt","rt"); if(fp==NULL) { puts("파일 오픈 실패!"); return -1; } for(i=0;i<5;i++){ fgets(str, sizeof(str),fp); printf("%s", str); }
fclose(fp); return 0; } |
BulletCtrl using UnityEngine; using System.Collections; public class BulletCtrl : MonoBehaviour { public Transform Tr; public float speed = 500.0f; public float damage = 10.0f;
private Vector3 spawnPoint; public float fireRange = 300.0f; // Use this for initialization void Start () { Tr = this.GetComponent<Transform>(); spawnPoint = Tr.position; }
// Update is called once per frame void Update () { Tr.Translate(Vector3.forward * Time.deltaTime * speed); if((spawnPoint - Tr.position).sqrMagnitude > fireRange) { RemoveBullet(); } }
void RemoveBullet() { StartCoroutine(this.DestroyBullet()); }
IEnumerator DestroyBullet() { Destroy(this.gameObject); yield return null; } } |
|
|
|
|
|
'C' 카테고리의 다른 글
Visual Studio 단축키 (0) | 2013.10.01 |
---|---|
구구단(입력된 단수부터 출력) (0) | 2013.09.02 |