69,371
社区成员
发帖
与我相关
我的任务
分享
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define MAX 41
int _tmain(int argc, char * argv[])
{
FILE *fp;
char words[MAX];
int count = 1;
char *count_c;
count_c = (char*)malloc(sizeof(char) * 4);
if ((fp = fopen("wordy", "a++")) == NULL)
{
fprintf(stdout, "Can't open \"wordy\" file.\n");
exit(EXIT_FAILURE);
}
puts("Enter words to add to the file; press the #");
puts("key at the begining of a line to terminate.");
while ((fscanf(stdin, "%40s", words) == 1) && (words[0] != '#'))
fprintf(fp, "%s\n", words);
puts("File contents:");
rewind(fp);
while (fscanf(fp,"%s", words) == 1)
{
_itoa(count,count_c,10);
printf("%s %s\n", count_c, words);
++count;
}
puts("Done!");
if (fclose(fp) != 0)
{
fprintf(stderr, "Error closing file\n");
}
free(count_c);
system("PAUSE");
return 0;
}
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <ctype.h>
#define Length 10
#define Amount 5
int _tmain(int argc, char * argv[])
{
struct three_name{
char last_name[Length];
char mid_name[Length];
char first_name[Length];
};
struct member{
char account[Length];
struct three_name name;
};
struct member m_member[Amount] = { { "101", { "aaa", "bb2", "dccc" } }, { "202", { "abb", .mid_name = "fccc" } }, { "303", { "acc", "bb4", "hccc" } }, { "404", { "add", "bb5", "fccc" } }, { "505", { "aee", "bb6", "ccc" } } };
system("PAUSE");
return 0;
}
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define Length 20
int _tmain(int argc, char * argv[])
{
char name[Length];
char ch;
int data_n[7][10] = {};
char data_i[8][10] = {};
FILE * fp;
char image_n[10] = { ' ', '.', '/', '-', '+', '*', '&', '^', '#', '@' };
int num = 0, value = 0;
printf("Please enter the file's name:");
scanf("%s",name);
if ((fp = fopen(name, "r")) == NULL)
{
printf("Cna't open %s file.", name);
exit(EXIT_FAILURE);
}
for (size_t i = 0; i < 7; i++)
{
for (size_t j = 0; j < 10; j++)
{
//fseek(fp, fp_n, SEEK_SET);
ch = fgetc(fp);
//ch = getc(fp);
value = (int)(ch - '0');
data_n[i][j] = value;
fgetc(fp);
//fp_n = fp_n + 2;
}
//fp_n = fp_n - 1;
}
for (size_t i = 0; i < 7; i++)
{
for (size_t j = 0; j < 10; j++)
{
num = data_n[i][j];
data_i[i][j] = image_n[num];
}
}
for (size_t i = 0; i < 10; i++)
{
data_i[7][i] = image_n[1];
}
for (si