str_cut

Posted By: Racebert69

str_cut - 05/06/12 19:41

can not convert 'ARRAY' to 'FIXED'
whats wrong?

(Sorry for too much code - I am testing for hours to read word by word with delimiters - ",")

Code:
#include <acknex.h>
#include <default.c>
#include <strio.c>

	STRING* wort;
	wort = "xx";
//	var woerter;
//	STRING* thisword;
//	thisword = "xxxxxx";
	STRING* zahl;
	var anzahl;
	anzahl = 0 ;
	
function main ()
{
//	STRING* wort;
//	wort = "xx";
	STRING* thisword;
	thisword = "xxxxxx";
	var woerter;
	STRING* ups;
	// START - Textdatei laden - Inhalt zum Lernprogramm 

	//var zahl;
   woerter = file_open_read("test2.txt");	
   // printf(woerter);	
	// ENDE  - Textdatei laden - Inhalt zum Lernprogramm 

   //file_str_readtow(woerter, thisword); 
   file_str_readtow(woerter , thisword , "" , 5000); 
   printf(thisword);
   anzahl = str_stri ( thisword , "," );
   printf(anzahl);
   wort = thisword;
   STRING* worte;
   worte = str_cut (NULL , wort , "g" , anzahl );
   printf(wort);
   printf(zahl);
   str_clip(thisword , anzahl + 1 );
   printf(thisword);
//   thisword = " - ";
//   file_str_readtow(woerter , thisword , "." , 20); 
//   printf(thisword);
//   thisword = " - ";
//   file_str_readtow(woerter , thisword , "." , 20); 
//   printf(thisword);
//   thisword = " - ";
//   file_str_readtow(woerter , thisword , "." , 20); 
   wort = thisword;
   printf(thisword);
//   file_chr_read(woerter, thisword);
//   printf(thisword);
	file_close(woerter);
}


Posted By: Tempelbauer

Re: str_cut - 05/06/12 22:58

your method-call is wrong:

Code:
worte = str_cut (NULL , wort , "g" , anzahl );



but the prototype says:

Quote:
str_cut(STRING* to, char* from, var start, var end)


the 3rd parameter has to be a var (the startindex) and not a string!
see http://www.conitec.net/beta/strio_c.htm


...and welcome to the forums laugh
Posted By: Racebert69

Re: str_cut - 05/06/12 23:29

yeah thx - after long testing I build in that error.

but the the script crashes also with:

worte = str_cut (NULL , wort , 1 , 10 );
Posted By: Tempelbauer

Re: str_cut - 05/07/12 12:29

is your string long enough? if you cut 1 char from the beginning and 10 from the end, your string should contain at least 11 characters
Posted By: frankjiang

Re: str_cut - 01/22/18 10:05

STRING* s = str_create("");
str_cpy(s,"abcdefg"); //1~3

int _s = 1;
int _e = 3;
str_clip(s,_s);
str_trunc(s,_e);

printf("%s",s->chars);
© 2024 lite-C Forums