Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,111 questions

40,781 answers

573 users

How to use typedef for char * in C

1 Answer

0 votes
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef char *StringP;

int main(void)
{
    StringP s;
    
    if ( (s = (StringP) malloc(16 * sizeof(char))) != NULL)
    {
        strcpy(s, "hello");
        puts(s);
        free(s);
    
    }
    
    return 0;
}


/*
run:
 
hello

*/

 





answered Dec 8, 2015 by avibootz

Related questions

1 answer 75 views
75 views asked Dec 6, 2015 by avibootz
1 answer 60 views
60 views asked Dec 29, 2021 by avibootz
1 answer 58 views
58 views asked May 7, 2021 by avibootz
3 answers 216 views
2 answers 120 views
120 views asked Aug 18, 2017 by avibootz
...