#include <stdio.h>
int main( void )
{
unsigned int i = 1;
int counter = 0;
while (i)
{
i <<= 1;
Type: Posts; User: char
#include <stdio.h>
int main( void )
{
unsigned int i = 1;
int counter = 0;
while (i)
{
i <<= 1;
#include <stdio.h>
int main( void )
{
unsigned int i = 2;
unsigned int mask = 2;
int counter = 1;
while ( i & mask )
{
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.
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...
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...
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...
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])
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...
#include <stdio.h>
#include <stdlib.h>
#define PATH "/usr/home/text"
int main(void)
{
char buf[BUFSIZ];
FILE *fp;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXWORDS 50
void insert_word(char **words, char *new_word);
int main(void)
{
#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)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXNAMES 5
int main(void)
{
char buffer[1024], *str_arr[MAXNAMES];
int i;
First of all, have you designed any algorithm for calculating the age?
Every array must have a size.
#define BUFSIZ 4096 /* for instance */
...
char buff[BUFFSIZ];
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(...
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.
You don't need to typedef your structure.
The first argument of fgets() must be a char *.
(There might be other errors)
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...
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...
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...
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...
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...
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...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define NUMBER_OF_STUDENTS 25
typedef struct
{
char name[30];
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;