Click here to Skip to main content
15,892,298 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
AnswerRe: passing javascript variable to php file without page refresh Pin
Mohammad Dayyan19-Jan-09 19:52
Mohammad Dayyan19-Jan-09 19:52 
AnswerRe: passing javascript variable to php file without page refresh Pin
Ranjit Viswakumar29-Jan-09 12:06
Ranjit Viswakumar29-Jan-09 12:06 
QuestionDoing encryption that embedded into mail server Pin
xiaomahe2-Jan-09 7:49
xiaomahe2-Jan-09 7:49 
AnswerRe: Doing encryption that embedded into mail server Pin
JasonPSage27-Feb-09 12:51
JasonPSage27-Feb-09 12:51 
QuestionAccessing ping through c/c++ Pin
tassadaque31-Dec-08 2:18
tassadaque31-Dec-08 2:18 
AnswerRe: Accessing ping through c/c++ Pin
Cosmic Egg10-Jan-09 4:03
Cosmic Egg10-Jan-09 4:03 
QuestionC programming in Linux warning message Pin
Kogee San9-Dec-08 17:24
Kogee San9-Dec-08 17:24 
AnswerRe: C programming in Linux warning message Pin
L. Madhavan17-Dec-08 17:58
L. Madhavan17-Dec-08 17:58 
It looks like you're trying to copy text into a string, but there are quite a few mistakes in the code:

1. A string is an array of characters, for eg. char str[100]. Therefore opt_socket_name[5] is a string that can hold 4 characters (+1 for the null terminator)

3. A * represents a pointer - you can also use a character pointer as a string, but it would point to an existing array of characters.

4. You use either * or an array. In your case, *opt_socket_name[5] means an array of 5 strings.

5. const = constant. Don't use that unless you don't want to modify the string.

So here's what your code should look like:
static char opt_socket_name[20];

main()
{
  strcpy(opt_socket_name, "testing");
  printf("%s", opt_socket_name);
}

If you're looking for an explanation for your warning and the segmentation fault, here it is: as I mentioned, in your original program, opt_socket_name[i] is a string and *opt_socket_name[i] points to a single character in the string. What you are passing to strcpy is a single character, which in C can be implicitly typecast to an integer, which in turn is typecast to a pointer and hence the warning.
GeneralRe: C programming in Linux warning message Pin
Kogee San18-Dec-08 0:45
Kogee San18-Dec-08 0:45 
GeneralRe: C programming in Linux warning message Pin
L. Madhavan18-Dec-08 1:15
L. Madhavan18-Dec-08 1:15 
GeneralRe: C programming in Linux warning message Pin
Kogee San18-Dec-08 20:54
Kogee San18-Dec-08 20:54 
QuestionPHP editor? Pin
blackhattrick9-Dec-08 7:48
blackhattrick9-Dec-08 7:48 
AnswerRe: PHP editor? Pin
L. Madhavan16-Dec-08 23:00
L. Madhavan16-Dec-08 23:00 
AnswerRe: PHP editor? Pin
jeffb4228-Jan-09 8:54
jeffb4228-Jan-09 8:54 
AnswerRe: PHP editor? Pin
Jules VDV29-Jan-09 8:36
Jules VDV29-Jan-09 8:36 
AnswerRe: PHP editor? Pin
JimmyRopes31-Jan-09 15:20
professionalJimmyRopes31-Jan-09 15:20 
Questionbookmarks Pin
chiangkinghu8-Dec-08 21:10
chiangkinghu8-Dec-08 21:10 
AnswerRe: bookmarks Pin
Ranjit Viswakumar29-Jan-09 12:12
Ranjit Viswakumar29-Jan-09 12:12 
AnswerRe: bookmarks Pin
EliottA2-Feb-09 2:36
EliottA2-Feb-09 2:36 
Questionto upload video in php Pin
umeshdaiya5-Dec-08 18:03
umeshdaiya5-Dec-08 18:03 
AnswerRe: to upload video in php Pin
Mohammad Dayyan10-Dec-08 23:47
Mohammad Dayyan10-Dec-08 23:47 
Questionajax problem Pin
umeshdaiya28-Nov-08 1:00
umeshdaiya28-Nov-08 1:00 
AnswerRe: ajax problem Pin
Mohammad Dayyan28-Nov-08 10:08
Mohammad Dayyan28-Nov-08 10:08 
AnswerRe: ajax problem Pin
Ranjit Viswakumar29-Jan-09 12:20
Ranjit Viswakumar29-Jan-09 12:20 
QuestionLinux web proxy Pin
Mekong River27-Nov-08 17:16
Mekong River27-Nov-08 17:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.