Search:

Type: Posts; User: char

Page 1 of 2 1 2

Search: Search took 0.00 seconds.

  1. Thread: How many bits?

    by char
    Replies
    12
    Views
    2,359

    #include int main( void ) { ...

    #include <stdio.h>

    int main( void )
    {
    unsigned int i = 1;
    int counter = 0;

    while (i)
    {
    i <<= 1;
  2. Thread: How many bits?

    by char
    Replies
    12
    Views
    2,359

    #include int main( void ) { ...

    #include <stdio.h>

    int main( void )
    {
    unsigned int i = 2;
    unsigned int mask = 2;
    int counter = 1;

    while ( i & mask )
    {
  3. Thread: How many bits?

    by char
    Replies
    12
    Views
    2,359

    Thank you guys! This was actually very...

    Thank you guys!

    This was actually very obvious.



    i < UINT_MAX


    will always be true since UINT_MAX is the upper limit for unsigned int. Declaring i as unsigned long fixes the problem.
  4. Thread: How many bits?

    by char
    Replies
    12
    Views
    2,359

    How many bits?

    I have written a little program to find out the amount of bits in an unsigned int. By some reason the program prints nothing. It just goes into an infinite loop. What is wrong?



    #include...
  5. Replies
    56
    Views
    24,275

    I think the reason why the OP is confused is that...

    I think the reason why the OP is confused is that he/she is not aware that the calling function is actually passing pointers to pointers to char. That means that void * is interpreted by the called...
  6. Replies
    7
    Views
    2,802

    The terminal driver returns when a line has been...

    The terminal driver returns when a line has been entered. Until then the OS keeps the input in a buffer located in its memory space. When the driver returns (like when user hits <enter>) the buffer...
  7. Replies
    5
    Views
    1,142

    int any(char s1[], char s2[]) { int i,j; ...

    int any(char s1[], char s2[])
    {
    int i,j;

    for(i = 0; s1[i] != '\0'; i++)
    {
    for(j = 0; s2[j] != '\0' && s2[j] != s1[i]; j++)
    ;

    if (s1[i] == s2[j])
  8. Thread: ar = &ar = &ar[0]

    by char
    Replies
    4
    Views
    1,321

    int ar[6]; ar is an array of 6 int. &ar is...

    int ar[6];


    ar is an array of 6 int.
    &ar is a pointer to an array of 6 int.

    The value ar is the address of the first element in the array.

    The address of an array is the address of the...
  9. Replies
    3
    Views
    1,246

    #include #include ...

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

    #define PATH "/usr/home/text"

    int main(void)
    {
    char buf[BUFSIZ];
    FILE *fp;
  10. Thread: sorting a string

    by char
    Replies
    3
    Views
    1,118

    #include #include #include...

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

    #define MAXWORDS 50

    void insert_word(char **words, char *new_word);

    int main(void)
    {
  11. Thread: validating input

    by char
    Replies
    15
    Views
    2,953

    #include #include int...

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

    int main(void)
    {
    int i, ch;

    printf("Enter a positive intiger\n");

    while(scanf("%d", &i) != 1 || i < 0)
  12. Thread: Array of Strings

    by char
    Replies
    8
    Views
    1,928

    #include #include #include...

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

    #define MAXNAMES 5

    int main(void)
    {
    char buffer[1024], *str_arr[MAXNAMES];
    int i;
  13. Thread: Please show me

    by char
    Replies
    5
    Views
    1,676

    First of all, have you designed any algorithm for...

    First of all, have you designed any algorithm for calculating the age?
  14. Replies
    18
    Views
    12,022

    Every array must have a size. #define...

    Every array must have a size.



    #define BUFSIZ 4096 /* for instance */

    ...

    char buff[BUFFSIZ];
  15. Replies
    18
    Views
    12,022

    while ( fgets( buff, BUFSIZ, fp ) != NULL ) { ...

    while ( fgets( buff, BUFSIZ, fp ) != NULL ) {
    fputs( buff, stdout );


    The first line will go through all lines in the file, one at a time, till fgets( ) returns NULL.

    When does fgets(...
  16. Thread: *function

    by char
    Replies
    3
    Views
    1,058

    I think a function name, much like an array name,...

    I think a function name, much like an array name, is just a pointer.



    int func( void );


    func is a pointer to a function, with no arguments, returning int.
  17. Thread: structure array

    by char
    Replies
    5
    Views
    1,273

    You don't need to typedef your structure. The...

    You don't need to typedef your structure.

    The first argument of fgets() must be a char *.

    (There might be other errors)
  18. Thread: Garbage values

    by char
    Replies
    2
    Views
    2,147

    When you define a variable you are telling the...

    When you define a variable you are telling the compiler to allocate memory for it. The compiler "chooces" a memory location for that variable. That memoty location is full of 1s and 0s and all those...
  19. Thread: Basic Concept

    by char
    Replies
    2
    Views
    1,260

    In C we have Declarations and Definitions....

    In C we have Declarations and Definitions. Declaration is like an alias, as you say. Definition is the process of allocating memory for that variable.

    When you declare a variable you are just...
  20. Thread: Header files

    by char
    Replies
    1
    Views
    861

    They are "part of C". This header files include...

    They are "part of C". This header files include prototype declarations to many functions that you will be using often, like printf (), scanf () and many more. They also include many constants and...
  21. Replies
    6
    Views
    10,853

    Re: freeing an array of structures

    The argument to free() must be a pointer, like free (&data[i]).

    free() is used on memory that has been dynamically allocated. If this is the case of your array then you may use free().

    It is...
  22. Thread: accept()

    by char
    Replies
    0
    Views
    1,431

    accept()

    Consider we have a server that forks children after accept() returns, each child handling a client connection.

    By using getsockname() and getpeername() I can see that all packets enter the server...
  23. Replies
    3
    Views
    2,015

    Both table and pLastStu are STRUCT*. It looks...

    Both table and pLastStu are STRUCT*. It looks correct to me.

    First off, as Hammer said, make names an array of an appropriate size, something like 50. If you decide to keep your names declared as...
  24. Replies
    3
    Views
    2,006

    #include #include #include...

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

    #define NUMBER_OF_STUDENTS 25

    typedef struct
    {
    char name[30];
  25. Replies
    18
    Views
    59,940

    char test [4096]; //seldom you will find lines...

    char test [4096]; //seldom you will find lines larger than this size



    The best way though is to check every single character in the file.




    int c, counter = 0;
Results 1 to 25 of 31
Page 1 of 2 1 2