我有一个 .txt 文件,我想使用 C 编程对其进行排序。我有以下代码用于对 .txt 文件进行排序:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX_LEN 100 // Length of each line in input file.
int main(void)
{
char *strFileName = "/home/milad/Desktop/ddd.txt";
char *strFileSummary = "/home/milad/Desktop/ddd2.txt";
char strTempData[MAX_LEN];
char **strData = NULL; // String List
int i, j;
int noOfLines = 0;
FILE * ptrFileLog = NULL;
FILE * ptrSummary = NULL;
if ( (ptrFileLog = fopen(strFileName, "r")) == NULL ) {
fprintf(stderr,"Error: Could not open %s\n",strFileName);
return 1;
}
if …Run Code Online (Sandbox Code Playgroud) 我正在学习C:如何通过迪特尔进行编程.在Pointers一章中,有这个示例代码:
#include <stdio.h>
#include <ctype.h>
void convertToUppercase(char *sPtr);
int main( void )
{
char string[] = "cHaRaCters and $32.98";
printf( "The string before conversion is: %s", string );
convertToUppercase( string );
printf( "\nThe string after conversion is: %s\n", string );
}
void convertToUppercase(char *sPtr)
{
while(*sPtr != '\0') {
*sPtr = toupper(*sPtr);
++*sPtr;
}
}
Run Code Online (Sandbox Code Playgroud)
当我编译它时,没有问题.但是当我运行它时,没有任何反应.我找不出有什么问题!