#why we use %s not % some other letters

1 messages · Page 1 of 1 (latest)

vestal notch
#

I just started learning, and in the video shows how to use integer and floating point number but I don't get why I have to type %s not something else...
is it like specific?

civic hatch
#

Ok so

#

a string, is an array of characters. Think of a string like so

#

'H', 'e', 'l', 'l', 'o'

#

alright

#

now

#

%s

#

intuitively could mean string no?

#

so if you want to input a variable into a predefined string

#

your gonna wanna tell the compiler what type of "thing" your inputing, so it can do the conversion

#

s = string, d = digit, c = character, f = floating point

vestal notch
#

oh I see

#

There is more variable tho right?

#

I changed floating point to C

#

I can't use the variable twice?

#

becs gpa didn't give the result

eternal pecan
#

gpa is a type float and you're using %c. c is for character (char)

#

If you look at what King Polar Bear sent you, you can see which letter you need to replace %c in your printf to properly do that.

vestal notch
#

yeah done

#

was just wondering why we used C,D,F etc

eternal pecan
vestal notch
#

thanks boys