void fillNewArray(char* inputFile, int line, int* array, int numElements){ int i = 0; //initialize array for(i = 0; i < numElements; i++){ array[i] = 0; } char string[MAX_SIZE]; getLineInFile(inputFile, line, string); char* token; token = strtok(string, "[,]"); int currentIdx = 0; int current; while(token != NULL){ sscanf(token, "%d", ¤t); if(currentIdx >= numElements){ break; } array[currentIdx++] = current; //Continue with next token token = strtok(NULL, "[,]"); } // // for(i=0; i < numElements; i++){ // printf("contents in loop[%d]: %d\n ", i, array[i]); // } }
void otput() { // //const char *msg="Hello World\n"; // printf("fileOperating is here \n"); // gint32 file=open("data",O_RDWR); // gchar buffer[128]; // gint32 haveRead=read(file,buffer,128); // //gint32 file=open("data",O_RDWR); // //gint32 haveRead=read(file,buffer,128); // buffer[haveRead]='\0'; // g_print ("%s,\n",buffer); // close(file); //// // // // char * getstr= getStrInFile("data",0,1); // int len=strlen(getstr); // int count=0; // while(len>=0) // { // int cc=getstr[count++]; // len--; // printf("%d",cc); // // // } // // printf("read str is here:%s",getstr); // int res=putStrInFile("data","=",1,0); //delStrInFile("data",4,3); // addLineToFile("data","\nim pig\n"); // int line=0; // int *loc= findAllLine("data",&line); // printf("line is%d \n",line); //// printf("%d \n",cc); // int len=line*2; // int count=0; // while(len>0) // { // int cc=loc[count++]; // len--; // printf("%d \n",cc); // } char * getstr= getLineInFile("data",4); if(getstr != NULL) { int len=strlen(getstr); int count=0; printf(" \nlast len is:%d \n",len); while(len>0) { char cc=getstr[count++]; len--; printf("%c \n",cc); } } // printf("read str is here:%s",getstr); }