In the C standard library, header names end with a .h suffix:

stdio.h

In C++, those header names are available in an alternative form, with a c prefix instead:

cstdio

Write a function that converts the first form into the second. You can do the conversion in-place, or leave the original string intact and return a new string. Whatever feelds natural in your language of choice.

The code must be compiled/interpreted without errors. Compiler warnings are acceptable.

Here is your baseline C solution. It has 70 characters and generates a warning about strlen:

void f(char*h){int i=strlen(h);h[--i]=0;while(--i)h[i]=h[i-1];*h='c';}

The shortest solution (measured in number of characters) wins.

Update: If your language of choice does not support functions, whole programs are also acceptable.

Update: As suggested by FUZxxl, here is a complete list of the header files in the C standard library:

assert.h
ctype.h
errno.h
float.h
limits.h
locale.h
math.h
setjmp.h
signal.h
stdarg.h
stddef.h
stdio.h
stdlib.h
string.h
time.h

Specifically, there are no header names with multiple dots in them.

# MS QuickBasic or QB64 ~ 33 bytes

A$=left$(A$,len(A$)-2)
A$="c"+A$

cstdio

## Excel formula, 36 bytes

If the header is put in cell A1,

=CONCATENATE("c",LEFT(A1,LEN(A1)-2))

### Explanation

=CONCATENATE("c",LEFT(A1,LEN(A1)-2))
=CONCATENATE(   ,                  )  Adds two strings
"c",                     The letter 'c'
LEFT(            )   Returns the specified # of chars from the beginning
A1,             Cell A1
LEN(A1)-2    The length of A1, minus 2 from the '.h'

# Whitespace, 63 bytes

[S S S T    T   S S S T T   N
_Push_99_c][T   N
S S _Print_as_character][N
S S N
_Create_Label_LOOP][S S S N
S_Push_0][S N
S _Duplicate][T N
T   S _Read_STDIN_as_character][T   T   T   _Retrieve][S N
S _Duplicate][S S S T   S T T   T   S N
_Push_46_.][T   S S T   _Subtract][N
T   S S N
_If_0_Jump_to_Label_EXIT][T N
S S _Print_as_character][N
S N
N
_Jump_to_Label_LOOP]

Letters S (space), T (tab), and N (new-line) added as highlighting only.

Try it online (with raw spaces, tabs and new-lines only).

Explanation in pseudo-code:

Print "c"
Start LOOP
Character i = STDIN as character
if(i == '.')
EXIT program (with error)
Print i
Go to next iteration of LOOP

# Japt, 7 6 bytes

ic ¯-2
ic     # Given the default input, prepend a 'c' at the start
¯-2 # and trim off the last two letters.

Try it online!

• Save a byte by omitting the '. – Shaggy May 14 '18 at 13:20
• @Shaggy Thanks, I often forget Japt handles inputs as defaulting to chars in these cases. – Nit May 14 '18 at 13:37

# Julia: 19 characters

f(s)="c"*s[1:end-2]

Sample run:

julia> f(s)="c"*s[1:end-2]
f (generic function with 1 method)

julia> print(f("stdio.h"))
cstdio

# Perl (program) 15

s/(.*)\.h/c\1/

It converts filenames supplied on std input, and needs to be run with the p flag, so that's one more character I believe. Eg

echo stdio.h | perl -p header.pl

output:

cstdio

Note to sticklers: I just spotted that this may be invalid because challenge implies that programs are only acceptable if the language doesn't support functions. However, I'm not going to throw it all away at this stage! Ah well.

Update: Augh! And I hadn't spotted page 2 of the answers either. Please refer to @malkaroee's effectively identical answer posted 4 months ago. ... Hang on, who resurrected this thread?

## Lua, 39 bytes

function f(n)return "c"..n:sub(1,-3)end

# C# 6, 52 bytes

class P{string C(string f)=>"c"+f.Replace(".h","");}

# C# <6, 58 bytes

class P{string C(string f){return"c"+f.Replace(".h","");}}

# TI-89 Basic, 56 bytes

:Def a(a)=Func
:Return "c"+sub(a,1,length(a)-2
:End Func

# MATLAB, 19

@(c)[99,c(1:end-2)]

Fairly straight forward. Prepends 'c' to the input string less the last two letters. MATLAB automatically converts the 99 (ASCII value) to 'c' when appending to a character string.

# Tcl, 36 bytes

proc H h {set s c[regsub ..h ""]}

Try it online!

# V, 5 bytes

éc$xx Try it online! Hexdump: 00000000: e963 2478 78 .c$xx

This is a full program that takes input from STDIN.

## Explanation

éc     insert the character 'c'
$go to the end of the line xx delete two characters This is ic<esc>$xx in pure Vim.

# 05AB1E, 5 bytes

¨¨'cì

Try it online.
Header ε is used to for-each over the input-list to verify all test cases instead of just one.
Footer is to close this for-each, and print the results with new-line delimiter.

Explanation:

¨¨       # Remove the last two characters of the input
ì    # Prepend:
'c     #  "c"
• Technically not competing since the whole language was made after the question was asked. – Nit May 7 '18 at 9:54
• @Nit Not anymore since the Summer of 2017. Relevant meta post. – Kevin Cruijssen May 7 '18 at 9:57
• Ah, didn't know that, thanks for the heads up. – Nit May 7 '18 at 10:02

# Stackers (27 bytes)

«h ®h 👁h cc ( ~ ~ 🖹

## Ungolfed Version

«h "define a table called h
👁h "read h to the stack
cc  "add the value for 'c' to the stack
(   "put c on the bottom of the stack
~ ~ "destroy the top two values on the stack
🖹   "print stack bottom two top

Stackers is a programming language I created myself that is meant to be based on stacks, with variables and tables thrown in

# SNOBOL4 (CSNOBOL4), 41 bytes

INPUT ARB . O RPOS(2)
OUTPUT ='c' O
END

Try it online!