c programming

dl324

Joined Mar 30, 2015
18,333
C doesn't have a string datatype. Strings are implemented as arrays of characters, usually null terminated.
 

WBahn

Joined Mar 31, 2012
32,870
What are the differences between string and character in c programming languages and their application?
Go to Google.com and type "What are the differences between string and character in c programming languages and their application?" in the search bar.

Read what some of the offered links say and, if you still questions, come back and ask specific questions about what is still unclear.
 

dl324

Joined Mar 30, 2015
18,333
what is character in c programming?
If you're referring to the char datatype, it's a single byte capable of storing one character.

Ascii character set:
Code:
       For convenience, below are more compact tables in hex and decimal.

          2 3 4 5 6 7       30 40 50 60 70 80 90 100 110 120
        -------------      ---------------------------------
       0:   0 @ P ` p     0:    (  2  <  F  P  Z  d   n   x
       1: ! 1 A Q a q     1:    )  3  =  G  Q  [  e   o   y
       2: " 2 B R b r     2:    *  4  >  H  R  \  f   p   z
       3: # 3 C S c s     3: !  +  5  ?  I  S  ]  g   q   {
       4: $ 4 D T d t     4: "  ,  6  @  J  T  ^  h   r   |
       5: % 5 E U e u     5: #  -  7  A  K  U  _  i   s   }
       6: & 6 F V f v     6: $  .  8  B  L  V  `  j   t   ~
       7: ' 7 G W g w     7: %  /  9  C  M  W  a  k   u  DEL
       8: ( 8 H X h x     8: &  0  :  D  N  X  b  l   v
       9: ) 9 I Y i y     9: '  1  ;  E  O  Y  c  m   w
       A: * : J Z j z
       B: + ; K [ k {
       C: , < L \ l |
       D: - = M ] m }
       E: . > N ^ n ~
       F: / ? O _ o DEL
 

WBahn

Joined Mar 31, 2012
32,870
Datatypes are essentially collections of bits.
char or uint8_t is 8 bits.
While uint8_t, if supported, is 8 bits, the width of a char (and whether it is signed or unsigned) is implementation-dependent and must only be at least eight bits. It is also required to be large enough to represent every character in the basic execution character set, so an implementation whose basic execution character set exceeds 8 bits would have to be larger. Having said that, I'm not aware of any implementations for which a char is larger than eight bits, but I program in English, so that might give me too narrow a view of the worldwide C implementations.
 

WBahn

Joined Mar 31, 2012
32,870
It's architecture dependent. Honeywell 6000 used 9 bits for char.
I'd love to have some of the numbers about those machines. I know in the 1980 time frame they were screaming along about just under 2 MIPS and could accommodate 256 kwords of memory (36 bit words), so a megabyte (of 9-bit bytes). I'd like to have a feel for how much they cost at the time.

The C-standard definitely reflects the variable byte sizes of the day. It explicitly defines a byte as an "addressable unit of data storage large enough to hold any member of the basic character set of the execution environment". Although the "byte" used more broadly at the time was usually meant to refer to the atomic data element of the processor (the smallest amount of data that could be address and read/written in the architecture) and the C standard doesn't mandate smallest addressable unit, not even with the caveat that the floor is that it has to be large enough for the character set. I doubt this was an oversight, but rather just another example of them putting as few constraints on the implementation as the could.
 

ApacheKid

Joined Jan 12, 2015
1,762
what is character in c programming?
A good question! In the modern world a "character" can be 1, 2, 3 or even 4 bytes, this is because since C was first crafted the world has moved on and there are a plethora of encodings around now.

In C# for example a "char" (as distinct from a "byte") is 16 bits.
 

WBahn

Joined Mar 31, 2012
32,870
Apparently they leased them for $20,000+/month.
Thanks! I see that it says that monthly rentals ranged from $20k/mo to "well over" $100k/mo (in 1972).

I don't know how that machine (say the base model) really compares to, say, my first computer which was an 8088-based TI Pro with 768 kB RAM and an 8087 math co-processor running at 4.77 MHz. But I don't know what that translates to in MIPS since so many instructions take many cycles to complete. Still, I imagine it wasn't too far out of the ballpark and at $5k (with a ton of software, most of which never got used) in 1984, that really says a lot about how fast things changed.
 

dl324

Joined Mar 30, 2015
18,333
But I don't know what that translates to in MIPS since so many instructions take many cycles to complete.
As I recall, the 80386 was rated at 4 MIPS. We used a VAX 11/780 to design them; it was rated at 1 MIPS.

Earlier you referred to math co-processors. The 80386SX didn't have floating point, 80386DX did. You could add an 80387 to the SX to get floating point. As I recall, the 387 was actually a DX that disabled the SX. I worked on the SX.
 

ApacheKid

Joined Jan 12, 2015
1,762
As I recall, the 80386 was rated at 4 MIPS. We used a VAX 11/780 to design them; it was rated at 1 MIPS.

Earlier you referred to math co-processors. The 80386SX didn't have floating point, 80386DX did. You could add an 80387 to the SX to get floating point. As I recall, the 387 was actually a DX that disabled the SX. I worked on the SX.
There's an old story about Steve Jobs meeting Seymour Cray and telling him "Well we just ordered a Cray to help us design our next Apple PC" to which Cray replied "Really? We just ordered an Apple to help us design our next Cray!".
 
Top