User Profile

Collapse

Profile Sidebar

Collapse
mohammadazim
mohammadazim
Last Activity: Dec 1 '07, 01:15 PM
Joined: Aug 31 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • mohammadazim
    replied to typedf inC++
    in C
    typedef int main(void);
    See more | Go to post

    Leave a comment:


  • Well it is relevent to C language in which if you use an enum or structure which are user defined data types, you need to specify the enum or struct keyword while using it.
    For example you define a struct as
    struct myStruct
    {
    int a;
    char c;
    }

    Now when you want to use it you will do as

    struct myStruct s;
    s.a = 10;
    s.c = 'b';

    to avoid...
    See more | Go to post

    Leave a comment:


  • mohammadazim
    replied to +operator
    in C
    Take this example. Suppose you have class Node and it has a + operator defined like this
    Node Node::operator + (Node node)
    {
    /*implementation of +*/
    }
    Imporatnt thing to understand is how this is used when we have statement like
    Node a,b;
    Node c = a + b;

    Here a is the object of Node whose operator + function is called. b is the object whose value is passed as argument to operator...
    See more | Go to post

    Leave a comment:


  • mohammadazim
    replied to C program
    in C
    I think this is your college/school assignment. According to posting guidlines no one can post code as response.As nobody is here for spoon feeding.
    But I can show you the way. This is not difficult. For linklists read data structures using C and C++ by Tenenbaum and for file reading writing you can google as I don't know any book and you can do it your self
    See more | Go to post

    Leave a comment:


  • mohammadazim
    replied to Trouble with the While Statement
    in C
    You can move your prompt to hours in the loop and use a break statement to come out of loop. Like this...

    Code:
    //cout << "Enter hours worked or -1 to end: ";
    //cin >> hours;
    // move the above two inside the loop.
     
    while (1) // make loop unconditional.
    {
       cout << "Enter hours worked or -1 to end: ";
       cin >> hours;
    //  ... and
    ...
    See more | Go to post

    Leave a comment:


  • mohammadazim
    replied to how to write data on the memory
    in C
    Hi friend,

    You can't do that. I think I understood your requirement. You want to write data on ram from say 0x00fadced some addrss to some range. This not possible.
    First thing is a programer can never tells the machine to write at a specific address unless the address is of a hardware port(That are fixed).
    To write to memory you first need to allocate memory. There are two memory areas HEAP and STACK from where mempry...
    See more | Go to post

    Leave a comment:


  • mohammadazim
    replied to Operator overload for unary '++' operator
    in C
    This may be your compiler. Single operator overloading works for both A++ and ++A with Turbo C++ and Borland compiler. For others it may not. In orignal C++ designed by Stroustrup for post fix you need to do like:
    operator ++(int);
    Here int argument is automatically replaced by a 0. This extra argument helps compiler to distinguish between to forms.
    See more | Go to post

    Leave a comment:


  • mohammadazim
    replied to typedf inC++
    in C
    You are tring to do typedef of a function definetion. That is not possible.
    You can do typedef of a function declaration as
    typedef int main(void);
    but then it won't allow you to define main in the same file and if you write a c program without a main, it will give linking error "undefined reference to main".

    But I don't understand why you want to do this. Actually we do tydef so that we can use the...
    See more | Go to post

    Leave a comment:


  • Hi I figured it out in a way.
    I added an h and c file to my code having wrappers over read and write sys calls. Compiled them with C compiler. And used the c header in the code where I needed read and write with C lang linkage specifier.
    It works fine now.
    See more | Go to post

    Leave a comment:


  • mohammadazim
    replied to Error pthread_id_np_t undeclared
    in C
    Sorry I thought you never used pthread.

    Here is valuable quote that I found on http://publib.boulder.ibm.com/infoce...s/users_23.htm

    "The i5/OS machine implementation of threads provides a 64-bit thread ID. The thread ID is returned as a structure containing the high and low order 4 bytes of the 64-bit ID. This allows applications created by compilers that do not yet support 64-bit...
    See more | Go to post

    Leave a comment:


  • mohammadazim
    replied to Error pthread_id_np_t undeclared
    in C
    if you want to use thread then you can use pthread_t instead of `pthread_id_np_ t'. Then do a pthread_create to create it.

    instead downloading some code try downloading some tute and try yourself.

    Secondly, while specifing pthread library while compiling it should be -lpthread. That is -l<libname>. Or if you are on Ubunto or some other platform that don't need 'l' to identify a library then it is fine....
    See more | Go to post

    Leave a comment:


  • Above solution is good. But if you some computing you can do as following pseudo code
    Code:
    number = user input
    numberDigits = 1
    place = 10
    while number >= place
    {
    numberDigits++
    place *= 10
    }
    output number...
    See more | Go to post
    Last edited by pbmods; Nov 30 '07, 12:06 AM. Reason: Added CODE tags.

    Leave a comment:


  • Oh sorry! There is one mistake in your server code which is causing this problem. This is your read () and write () system calls.
    You need socket read and write calls and not file descriptor read write. Actual synopsis of socket read and write calls is as:

    int countOfBytes read (int socketDescripto r, char * buffer, int numberOfBytesRe ad, int socketFlags)

    int countOfBytes write(int socketDescripto r, char * buffer,...
    See more | Go to post

    Leave a comment:


  • This can not happen because loop has read system call. It is a blocking system call and waits untill new data is received on socket. What is your client program. looks that is sending data continously. Are you using send () in client program. That keeps sending if some thing is in buffer. Try using write there also. Your server code looks fine....
    See more | Go to post

    Leave a comment:


  • mohammadazim
    replied to New to Unix!!!
    what do you mean by "move into it and then save it to a flash drive." ?...
    See more | Go to post

    Leave a comment:


  • Following are the headers I have included in both the programs.
    #include <netinet/in.h>
    #include <linux/socket.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netdb.h>

    C code:
    13 memset(buff, '\0', BUFFLEN);
    14 if (read(sock, buff, BUFFLEN, flags) < 0){/*error handling*/}
    15 printf("[SERVER] %s", buff);...
    See more | Go to post

    Leave a comment:


  • Socket program in c++. gives "‘read’ was not declared " error on read () system call

    Hi guys I wrote a socket program in c++ and used blocking system call read () for receiving data on socket. But it gives following error while compilation

    [HTML]g++ -Wall -g -I`pwd`/../include -lpthread -c SocketDescripto r.cc -o `pwd`/../lib/SocketDescripto r.o
    SocketDescripto r.cc: In member function ‘Status SocketDescripto r::Recv(int&, unsigned char*, int&)’:
    SocketDescripto r.cc:79: error: ‘read’ was...
    See more | Go to post

  • Hi want to update you all. Sorry for this late update!

    I figured it out by upgrading gcc to 4.1.1-51 version. Since I downloaded latest kernel from net I should upgrade gcc to latest as always latest kernels are compiled on latest gcc before release....
    See more | Go to post

    Leave a comment:


  • Can't compile kernel-2.6.15-1.54 with gcc 4.1.0

    Hi,

    I am trying to compile kernel 2.6.15-1.54 of FC5. in BUILD/2.6.15-1.2054/README it says gcc should be above 3.2.0. I have gcc 4.1.0 but I am getting a lot of warning messages like:
    CC [M] fs/xfs/xfs_bmap.o
    fs/xfs/xfs_bmap.c: In function ‘xfs_bmap_alloc ’:
    fs/xfs/xfs_bmap.c:2326 : warning: ‘rtx’ is used uninitialized in this function

    when I do make and it gives error when I do 'make modules'....
    See more | Go to post
    Last edited by mohammadazim; Sep 8 '07, 03:03 PM. Reason: Added warning message for ref..

  • mohammadazim
    replied to Find prime numbers using loops
    in C
    You can try implementing following pseudo code

    generatePrimeNu ms routine:
    prime = 2 // start from 2. since 0 n 1 are not...
    loop till the number you want primes
    {
    checkPrime(prim e)
    ...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...