Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,138 members, 7,814,989 topics. Date: Thursday, 02 May 2024 at 03:55 AM

Creating A Bit Adt In C - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Creating A Bit Adt In C (1569 Views)

Creating UWP Application In C# Or C++ (xaml) / Creating A Group Chat With Html/javascript/php/mysql For Beginners / [problem] Write A Program In C++ That Finds The Hcf Of 2 Numbers Without Using A Recursive Function (2) (3) (4)

(1) (Reply)

Creating A Bit Adt In C by logic101: 1:39pm On Nov 20, 2011
Hi i am trying to create a bit data structure to holds sets  but am trying to put in values into my memory but its not working out for me.sample i using a set of alphabets because it is small enough.

/*
* File:   main.c
* Author: stephen
*
* Created on November 20, 2011, 10:04 AM
*/

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

/*
*
*/


struct bitset{
   int size;
   unsigned char *contents;
   


};

struct bitset * bitset_new(int size){
//   return -1;
   struct bitset *p;
    p == malloc(sizeof(*p));
    p->contents= malloc((sizeof(char) * size/cool + (size%cool?0:1);
    return p;
   
   
}

// add an item, with number 'item' to the set
// (returns 0 if item is out of bounds, 1 otherwise)
// has no effect if the item is already in the set
int bitset_add(struct bitset * this)
{
    return 1;
     char *p;
    printf ("Please enter a line of text, max %d characters\n",
    sizeof(this->contents));
   
  if (fgets(this->contents, sizeof(this->contents), stdin) != NULL)
  {
    printf ("Thank you, you entered >%s<\n", this->contents);
   
  }
    if ((p = strchr(this->contents, '\n')) != NULL)
      *p = '\0';
     
    //return 0;
}



int main(int argc, char** argv) {

    //unsigned char a='a';
   // unsigned char b='b';
   // unsigned int m=1;
   // unsigned int j=0;
   // int c=m |j;
  //  int e= sizeof(char);
   
    struct bitset *p= bitset_new(26);
    bitset_add(&p);

   
 
 
   
    return (EXIT_SUCCESS);
}
Re: Creating A Bit Adt In C by nnaobodo1: 3:00pm On Dec 08, 2011
@logic101,

i need to understand C programming language,
i amm trying to write an interactive words on C.
how do i go abt it?
Re: Creating A Bit Adt In C by Nobody: 8:13pm On Dec 09, 2011

(1) (Reply)

Figure Out The Error Please (PHP And Mysql)!!! / Content Delivery Network (CDN) / Pls I Need Your Help Concerning My Assignment 2 (database)

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 8
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.