Changeset d2e6f84


Ignore:
Timestamp:
Sep 15, 2025, 9:22:48 PM (5 days ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
96aca388
Parents:
4b465445
Message:

clean up string discussion

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/user/user.tex

    r4b465445 rd2e6f84  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Mon Sep 15 17:06:25 2025
    14 %% Update Count     : 7216
     13%% Last Modified On : Mon Sep 15 21:14:57 2025
     14%% Update Count     : 7220
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    24412441The maximum storage for a \CFA ©string© value is ©size_t© characters, which is $2^{32}$ or $2^{64}$ respectively.
    24422442A \CFA string manages its length separately from the string, so there is no null (©'\0'©) terminating value at the end of a string value.
    2443 Hence, a \CFA string cannot be passed to a C string manipulation routine, such as ©strcat©.
     2443Hence, a \CFA string cannot be passed to a C string manipulation function, such as ©strcat©.
    24442444Like C strings, characters in a ©string© are numbered from the left starting at 0 (because subscripting is zero-origin), and in \CFA numbered from the right starting at -1.
    24452445\begin{cquote}
     
    26262626cs - cs2;       §\C{// find pointer offset}\CRT§
    26272627\end{cfa}
    2628 addition is less obvious:
     2628addition is less obvious
    26292629\begin{cfa}
    26302630ch + 'b'        §\C[2in]{// add character values}§
     
    26752675s = 'x' * 3;
    26762676s = "abc" * 3;
    2677 s = ("Peter" + ' ') * 3;
     2677s = ("PETER" + ' ') * 3;
    26782678\end{cfa}
    26792679&
     
    26822682"xxx"
    26832683"abcabcabc"
    2684 "Peter Peter Peter "
     2684"PETER PETER PETER "
    26852685\end{cfa}
    26862686\end{tabular}
     
    29532953\begin{figure}
    29542954\begin{cquote}
    2955 \setlength{\tabcolsep}{15pt}
    29562955\begin{tabular}{@{}l|l@{}}
    29572956\multicolumn{1}{c}{\textbf{\CC}} & \multicolumn{1}{c}{\textbf{\CFA}} \\
     
    29992998Hence, it is possible to convert a block of C string operations to \CFA strings just by changing the type @char *@ to @string@.
    30002999\begin{cquote}
    3001 \setlength{\tabcolsep}{15pt}
    30023000\begin{tabular}{@{}ll@{}}
    30033001\begin{cfa}
     
    30283026A comparison with \CC string I/O is presented as a counterpoint to \CFA string I/O.
    30293027
    3030 The \CC ooutput ©<<© and input ©>>© operators are defined on type ©string©.
     3028The \CC output ©<<© and input ©>>© operators are defined on type ©string©.
    30313029\CC output for ©char©, ©char *©, and ©string© are similar.
    30323030The \CC manipulators are ©setw©, and its associated width controls ©left©, ©right© and ©setfill©.
    30333031\begin{cquote}
    3034 \setlength{\tabcolsep}{15pt}
    30353032\begin{tabular}{@{}l|l@{}}
    30363033\begin{C++}
     
    30503047The \CFA manipulators are ©bin©, ©oct©, ©hex©, ©wd©, and its associated width control and ©left©.
    30513048\begin{cquote}
    3052 \setlength{\tabcolsep}{15pt}
    30533049\begin{tabular}{@{}l|l@{}}
    30543050\begin{cfa}
     
    30793075Reading into a ©char© is safe as the size is 1, ©char *© is unsafe without using ©setw© to constraint the length (which includes ©'\0'©), ©string© is safe as its grows dynamically as characters are read.
    30803076\begin{cquote}
    3081 \setlength{\tabcolsep}{15pt}
    30823077\begin{tabular}{@{}l|l@{}}
    30833078\begin{C++}
Note: See TracChangeset for help on using the changeset viewer.