Search:

Type: Posts; User: sganesh

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds.

  1. Replies
    17
    Views
    2,899

    This is just a sample code. I hope this will help...

    This is just a sample code. I hope this will help you.


    #include<stdio.h>
    int main()
    {
    char *q[]={ "c", "c++", "java" };
    srand(time()); // It will set the seed as epoch second...
  2. Replies
    17
    Views
    2,899

    * you can have the 10 questions in an array of...

    * you can have the 10 questions in an array of strings.
    * Then using rand() function or your own random algorithm you can generate any random numbers.
    * Then you can use that random number as an...
  3. Replies
    3
    Views
    9,752

    Some of the mistakes you have done in your...

    Some of the mistakes you have done in your program,

    note one thing array will have the memory less than you allocate.For ex: arr[10] will have 0-9

    * printf("%f", arraysums[9][2]);
    you need...
  4. Replies
    10
    Views
    23,343

    Re: Copying structures containing pointers

    obj2=obj1;
    (*obj2.x1)++;
    printf("obj2 %d mem(%d):%d\n",*obj2.x1,obj2.x1,obj2.x2);
    printf("obj1 %d mem(%d):%d\n",*obj1.x1,obj1.x1,obj1.x2);


    It gives output as ,
    obj2 41 mem(163155976):20...
  5. Replies
    10
    Views
    23,343

    Re: Copying structures containing pointers

    Normally, we can copy the structures in a two way.

    * Assigning structure using assignment operator


    obj2=obj1;
    obj2.x1 = malloc(5*sizeof(int));


    * And you can copy the structure using...
  6. Replies
    9
    Views
    2,678

    Re how to solve this question?

    Actually, K&R used 31. Because it is an odd prime number. And in ASCII table up-to 31 characters are non-printable character.

    And it will give less no of collisions.

    And note that expression...
  7. Replies
    4
    Views
    1,495

    Re: not looping after if()

    Try this code, it will solve your requirement.



    #include <stdio.h>

    int main()
    {
    int user_input, loop = 1;
    char rept;
  8. Replies
    13
    Views
    13,190

    Re: Average of user inputs (in a loop)

    Yeah.



    #include <stdio.h>

    int main()
    {
    int user_input = 1;
    int loop_count = -1;//starts with -1 because the exit input (final input) is ignored in the count
  9. Replies
    4
    Views
    1,953

    Re: Problem with sscanf

    For variable number of arguments you can use ... (ellipsis notation ) in function declaration and definition.

    And for getting those argument you can read about these functions and get to know...
  10. Replies
    8
    Views
    9,333

    Re: Read from file - 1-digit and 2-digit numbers

    Do you want to count how many times number 1 occurs in the file?
    If it is your requirement you can solve easily.



    #include <stdio.h>
    #include <stdlib.h>
    #include<string.h>
    int main() {...
  11. Replies
    6
    Views
    2,279

    Re: write a function to retern char **

    It may be the problem.
    I think you are using character type as Char rather than char.
    while declaring and defining getNextCommand function

    And I am using cc compiler.
  12. Replies
    6
    Views
    2,279

    In C, we can declare function with return type...

    In C, we can declare function with return type char **.
    It won't give the error if you returned the pointer to a character pointer in a function.
    I just tried some program. It won't be a useful...
  13. Replies
    8
    Views
    9,333

    Re: Read from file - 1-digit and 2-digit numbers

    you can follow these steps,

    * Get the numbers.
    * find the digit for that number like,


    if(num==0)
    digit=1;
    else
    for(digit=0;num!=0;num/=10,digit++);
  14. Replies
    4
    Views
    3,240

    Re: sscanf question

    yeah you can give like,



    sprintf(format, "%%%ds", SIZE);
    sscanf(buf, format, name);


    If you didn't specify the length also name will store only SIZE no. of characters.
    If free location is...
  15. Replies
    2
    Views
    3,142

    Re: Debugging an IF statement

    If you give the declaration statement of myarray it will easy to say answer.

    And you can check whether myarray[0] it is NULL or empty string.
    or try to print what value myarray contains.


    ...
  16. Replies
    9
    Views
    4,883

    Re: Animation using loop and pictures

    I know we can read the image file contents. But I don't know we can display or not.

    For that I searched and I got his URL this can be useful for you. But If you have graphics.h then only you can...
  17. Thread: scanf question

    by sganesh
    Replies
    6
    Views
    7,595

    Re: scanf question

    Actually, your syntax is wrong.
    scanf("%*[^0-9]d");

    Normally, If you used %d in scanf it will read only digits.
    For Ex: If I give 123abc it will take only 123. But if you give abc123. It will...
  18. Re: Printing random decimal numbers in a text file

    Yeah. you made mistake in calculation.
    random = (rand()%32767+1)/32767;

    It takes 32767 values integer and this (rand()%32767+1) value as float. so it returns 0.000000

    Change the calculation...
  19. Replies
    5
    Views
    1,197

    Re: Hijacked: What's my number?

    Float is a single precision number. But double has double precision.
    And it has difference in storage format.
    float has 4 bytes but double has 8 bytes.

    Try to differentiate with the printf...
  20. Replies
    5
    Views
    1,056

    Re: PROBLEM W/ EVALUATE....plz help me!

    I changed added two conditions in your code its working fine.

    1. In the infix2postfix function while checking the operator pop function returns -1. so it adds that is also in stack. so after...
  21. Re: Creating an english dictionary using c n data structures

    You can try Hash lookup table in C.
    In dictionary, searching should be faster. So it can be useful that.
  22. Replies
    4
    Views
    1,182

    Re: types and string conversion

    I think you have solved your requirement I don't know where are you confusing?
    But only one mistake I found that is why are you selecting array of pointers for storage.



    #include <stdio.h>...
  23. Replies
    6
    Views
    25,226

    Re: write error with a bad file descriptor

    If the error comes in a regular shell then the problem is that your quota or storage memory exceeded.
    If you are trying to create your own shell then the problem may be in your program.
  24. Replies
    12
    Views
    3,733

    Actually, I didn't use the msg->dsize as a first...

    Actually, I didn't use the msg->dsize as a first parameter of memcpy() I think you only used in your question.
  25. Replies
    12
    Views
    3,733

    Re: memcpy(msg->data+msg->dsize, ..)

    I just wrote a program for copying the strings in the structure,

    If you want to copy the whole structure you can use the size of the structure in the memcpy.
    It will copy that many number of...
Results 1 to 25 of 57
Page 1 of 3 1 2 3