Please help me to understand this. When I compile this code (save as test.c)

 #include<stdio.h> 
#include<string.h> 
int main() 
{ 
char *targ = "xxxxxxxxxxxxxxxxxxx"; 
printf("%s", *targ); 
}

it shows this warning message

[Warning] deprecated conversion from string constant to 'char' [-Wwrite-strings]

And when I run this code it show me this message

test.exe has stopped working

Why it shows the warning message?? Is it not a valid way to print string as printf("%s", *str); If it is not a valid way then why it is not valid??

asked 06 Dec '16, 07:35

mars's gravatar image

mars
213


You may visit this link for better understanding your problem solution.

permanent link

answered 06 Dec '16, 15:36

csemominur23's gravatar image

csemominur23
615

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×56
×31
×9

question asked: 06 Dec '16, 07:35

question was seen: 566 times

last updated: 06 Dec '16, 15:36