Demo entry 6784577

StructSave.cpp

   

Submitted by anonymous on Mar 05, 2019 at 15:07
Language: C. Code size: 554 Bytes.

	printf("Enter An Employee's Name: ");
	while (scanf("%s", nameBuf) && strcmp(nameBuf,"exit")) {
		strcpy(perBuf.username, nameBuf);
		printf("Employee's Level: ");
		scanf("%d", &perBuf.level);
		printf("Employee's Email: ");
		scanf("%s", emailBuf);
		strcpy(perBuf.email, emailBuf);
		(void)time(&now);  // 取得系统时间
		perBuf.sendtime = (DWORD)now;
		perBuf.regtime = now;
		// 将缓冲块数据写入文件中 
		if (fwrite(&perBuf, sizeof(Person), 1, wFile) != 1)
			printf("File Write Error\n");
		printf("\nEnter An Employee's Name: ");
	}
	fclose(wFile);

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).