Thread: Assignig string to array and compare it....???

  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    20

    Assignig string to array and compare it....???

    i have this code :

    Code:
    #include <errno.h>
    #include <stdio.h>
    #include <sys/types.h>          
    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <arpa/inet.h>
    #include <stdlib.h>
    #include <string.h>
    #include <unistd.h>
    #include <stdarg.h>        /* ANSI C header file */
    #include <syslog.h>        /* for syslog() */
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <fcntl.h>
    
    
    /* Following shortens all the typecasts of pointer arguments: */
    #define    SA    struct sockaddr
    #define ListenQ 5
    #define    MAXLINE        4096    /* max text line length */
    
    pid_t childpid;
    int        daemon_proc;        /* set nonzero by daemon_init() */
    
    /* this is global variable to define requiremnt parametrs for sockets */
    int listenfd,connfd,portno,stringlen;
        socklen_t clilen;
        char buffer[1024];
        struct sockaddr_in servaddr;
        int n;
        int sockfd,fd ; //for client socket
        
        char fileName[128];
        
        strncpy(fileName,"hello",128);
        int CmpValue;
        
    
    
    static void    err_doit(int, int, const char *, va_list);
    void str_fun(int Connfd);
    void err_msg(const char *fmt, ...); /* to use this prototype in str_fun */

    and this error occued with me i dont know why ???

    myHeader.h:42:19: error: expected ‘)’ before string constant


    **This code is compiled from file called myHeader.h ...

  2. #2
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Code:
        strncpy(fileName,"hello",128);
    you cannot have a function call outside of any function block
    Kurt

  3. #3
    Registered User
    Join Date
    Feb 2013
    Posts
    20
    Really really thanks i have no idea how i forgot this info

    thnx,

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Read and compare file contain array of string
    By didinj in forum C Programming
    Replies: 6
    Last Post: 12-13-2012, 03:30 AM
  2. Can't string compare
    By Konstantinos in forum C Programming
    Replies: 5
    Last Post: 11-05-2012, 03:04 PM
  3. Unable to compare string with 'getter' returned string.
    By Swerve in forum C++ Programming
    Replies: 2
    Last Post: 10-30-2009, 05:56 PM
  4. Replies: 7
    Last Post: 05-11-2008, 10:57 AM
  5. need help on string compare
    By Unregistered in forum C Programming
    Replies: 9
    Last Post: 06-07-2002, 08:55 PM

Tags for this Thread