Search:

Type: Posts; User: rassul

Search: Search took 0.00 seconds.

  1. Replies
    1
    Views
    549

    Your code works based on the following...

    Your code works based on the following conditions:
    If the left parenthesis follows 'if' (no spaces in between), such as if(, but it will not work for if (.
    If you are not using comments in your...
  2. Replies
    2
    Views
    815

    while(finished == 0){ printf(" \n Enter...

    while(finished == 0){
    printf(" \n Enter your desired operation (+, -, *, / or exit): ");
    while((o = getchar()) != '\n' && o != EOF); // clear input buffer
    scanf("%c", &o);...
  3. laserlight is right, we should use fflush...

    laserlight is right, we should use fflush function for output, therefore instead of using fflush we can clear the input buffer like:

    while((O = getchar()) != '\n' && O != EOF);
    and then call...
  4. You will need to read about scanf and getchar...

    You will need to read about scanf and getchar functions. Here is what is happening, let's focus on second scanf:
    scanf("%d", &B2);
    Suppose you type 5 and hit the enter key, now scanf takes only...
  5. Thank you Salem and others for helping. My...

    Thank you Salem and others for helping. My question was answered by you wonderful/helpful people. Case closed.
  6. char (*lines)[5]; lines = malloc(10 *...

    char (*lines)[5];


    lines = malloc(10 * sizeof(*lines)); // allocate 10 arrays and each array is 5 characters long

    now I need a function that takes entire 'lines' :


    someFunc(char ?????,...
  7. First, I want to thank you for your answer. Now...

    First, I want to thank you for your answer. Now my second question is, if I need a function that takes 'lines', how do I define the parameter and how I call the function with respect to passing...
  8. How to allocate memory for an array of strings?

    I have the following declaration:

    char (*lines)[5];

    I need to allocate 10 strings, and each string is 5 characters long. I used the following but did not seem to work.

    lines = malloc(10 *...
  9. Replies
    4
    Views
    3,826

    Thanks Tony, your suggestion worked.

    Thanks Tony, your suggestion worked.
  10. Replies
    4
    Views
    3,826

    2-Dimensional character strings and realloc()

    Hello, the following code fails/crashes in the second loop where it prints the content and frees the memory. But the issue could be with the first loop. Any help is appreciated in advance.



    int...
  11. Replies
    24
    Views
    2,323

    The following program now works. But my question...

    The following program now works. But my question is if:
    PTR ptr; and TEST **ptr; are the same what do I gain by using typedef TEST **PTR;
    Please help since I am trying to understand typedef's...
  12. Replies
    24
    Views
    2,323

    It crashes and does not even print "1- debug..."...

    It crashes and does not even print "1- debug..."

    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <malloc.h>

    struct _TEST
    {
    char msg[250];
  13. Replies
    24
    Views
    2,323

    This is not an assignment nor a project, simply...

    This is not an assignment nor a project, simply reviewing struct, typedef, and pointers in combination for learning purposes, because in real world you will this kind code a lot!
  14. Replies
    24
    Views
    2,323

    Well, I am not a student rather an old programmer...

    Well, I am not a student rather an old programmer trying to refresh my C language. I actually have the following but it crashes when I ran it.

    #include <stdio.h>
    #include <string.h>
    #include...
  15. Replies
    24
    Views
    2,323

    Struct and pointer

    Hello, please someone show me the code for what is asked the in
    the following program's comments for the variable ptr.

    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include...
  16. Thread: Array question

    by rassul
    Replies
    11
    Views
    1,367

    Array question

    The following program compiles (using MS Visual Studio 2010) with no errors or warnings and runs without any error, why? Thanks in advance for explanation.


    #include <stdio.h>

    int f[3] = {...
  17. Replies
    4
    Views
    8,135

    This is how I did it using macro: #define...

    This is how I did it using macro:

    #define arrayToString(name, digest) { char p[3]; int i; \
    for( i = 0; i < 16; i++ ){ \
    sprintf(p, "%02x", digest[i]); ...
  18. Replies
    4
    Views
    8,135

    Convert array to string

    I have the following code and need to convert the array into character string and print the value later as opposed to printing it via loop:

    int main( void )
    {
    int i;
    unsigned char...
  19. Replies
    1
    Views
    2,647

    Read Text File into an Array

    Hi, I need to use the qsort to sort the content of an unknown text file size by reading it into an array and then sort the lines. I know C language well, could someone help? I can get the file size...
  20. Replies
    6
    Views
    1,701

    Thank you all for your help.

    Thank you all for your help.
  21. Replies
    6
    Views
    1,701

    Overriding C run-time functions

    Hi, does anyone know how to override the C run-time functions. I need to write my own malloc() function with the same function signature as Microsoft's C run-time malloc(). Any suggestion/help? When...
Results 1 to 21 of 21