前一个数组附加到我想要的数组。我如何获得数组的第一部分?(输出的第一部分)。
int main(void) {
FILE *fIn, *csis;
if (fopen_s(&csis,"csis.txt","w") != 0) {
printf("Failed to open csis.txt for writing.\n");
}
if (fopen_s(&fIn,"congress.txt","r") != 0) {
printf("Failed to open congress.txt for reading.\n");
}
else {
char processTxt[500] , txtUpperCase[500] ;
processFile(fIn, processTxt, txtUpperCase);
printf(txtUpperCase);
fprintf(csis,"%s",txtUpperCase);
cipher(txtUpperCase, 13);
/*outputCode(txtUpperCase);*/
fclose(fIn);
fclose(csis);
}
return 0;
}
void processFile(FILE *fIn, char *processTxt, char *txtUpperCase) {
int i = 0, j = 0;
fgets(processTxt, g_size, fIn);
for (i = 0; i < g_size; i++) {
if (processTxt[i] == '\0')
break;
processTxt[i] = toUpper(processTxt[i]);
}
processTxt[i] = '\0';
for (i = 0; i < g_size; i++) {
if (processTxt[i] == '\0')
break;
if (isUpperCase(processTxt[i])) {
txtUpperCase[j] = processTxt[i];
++j;
}
}
char isLowerCase(char input) {
return (input>= 'a' && input <= 'z');
}
char isUpperCase(char input) {
return (input>= 'A' && input <= 'Z');
}
char toUpper(char input) {
char upperCase = input;
if (isLowerCase(input))
upperCase = (char)((int)input - 32);
return upperCase;
}
output: CONGRESSSHALLMAKENOLAWRESPECTINGANESTABLISHMENTOFRELIGIONORPROHIBITINGTHEFREEEXERCISETHERE FORABRIDGINGTHEFREEDOMOFSPEECHOROFTHEPRESSORTHERIGHTOFTHEPEOPLEPEACEABLYTOASSEMBLEANDTOPETITIONTHEGOVERNMENTFORAREDRESSOFGRIEVANCESÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌCONGRESS SHALL MAKE NO LAW RESPECTING AN ESTABLISHMENT OF RELIGION, OR PROHIBITING THE FREE EXERCISE THEREOF; 或剥夺言论自由或新闻自由;或人民和平集会的权利,以及向政府提出申诉的权利。
}