File: string.edp

package info (click to toggle)
freefem%2B%2B 3.47%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 132,088 kB
  • ctags: 19,726
  • sloc: cpp: 138,951; ansic: 22,605; sh: 4,951; makefile: 2,935; fortran: 1,147; perl: 768; awk: 282; php: 182
file content (70 lines) | stat: -rw-r--r-- 1,762 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//  bug string macro parameter   version < 1.41
// bug in string parameter version before <2.5
// -----------------

 macro tyty(uu) uu//  
cout << tyty("toto") << endl;

func string   write(string  fn,real[int] & u)
{
  cout <<"write :   " <<  fn << " u = "<<  u << endl;  //  delete 2 times before version 2.5 
  return fn; 
}

func string   write1(string  fn,real[int] & u)
{
  cout << "write 1 " << fn << " u = " << u << endl;   
  string toto=fn; ;
  return toto+"dfsdf"; 
}

real[int] u(3);
u=1;

string tt=tyty("toto1"+1+" -- 77");

string t1="0123456789";// write(tt,u);

string t2;


  {
    t2=  write1(t1,u)+write1(tt,u); // 
    // because the local variable of write1 are  delete 2 times at the  ;
    cout << " t2 = " << t2 << endl;
  }
if(0)
   { // the correct way
     t2=  write1(t1,u);
     t2=t2 + write1(tt,u); 
    cout << " t2 = " << t2 << endl;
   }
// new operator
t2 ="12340005678";
t2(4:3) = "abcdefghijk-"; 
string t55=t2(4:3);
//t2 = "12340abcdefghijk-005678";
cout << t2 << endl;
cout << "  find abc " << t2.find("abc") << endl;
cout << "r find abc " << t2.rfind("abc") << endl;
cout << " find abc from 10  " << t2.find("abc",10) << endl;
cout << " ffind abc from 10 " <<t2.rfind("abc",10) << endl;
cout << "   " << string("abcc").length << endl; 
cout << " t55 " << t55 << endl;
{  // add getline version 3.0-6 jan 2009 FH
string s;
ifstream toto("xyf");
for (int i=0;i<10;++i)
  {
   getline(toto,s);
   cout << i << " : " << s << endl;
  }
}
// add  3.29 + Stringification, LINE, FILE, ltime ..

macro aa()  "tyty"  //
cout << aa << endl; 
cout << "in " << FILE << " line " << LINE << "    -- '" << Stringification( "zzz" aa  () {} +  /* */  bb cc) << "'" << endl;
cout << " unix time = " << time() << " " << ltime() << endl;