(One intermediate revision by the same user not shown)
Line 1: Line 1:
= ECE 264 Exam 3 Open Book<br> =
+
[[Category:ECE264]] [[Category:Programming]] [[Category:C]]
 +
=[[ECE264|ECE 264]]: Exam 3 Review (Open Book) =
  
 
<br>Read Write fopen<br>Text fgetc fprintf "r", "w"<br>fgets fputc "rb", "wb"  
 
<br>Read Write fopen<br>Text fgetc fprintf "r", "w"<br>fgets fputc "rb", "wb"  
Line 46: Line 47:
  
 
<br><br>
 
<br><br>
 +
----
 +
[[2011_Spring_ECE_264_Lu|Back to ECE264, Spring 2011, Prof. Lu]]

Latest revision as of 05:32, 11 July 2012

ECE 264: Exam 3 Review (Open Book)


Read Write fopen
Text fgetc fprintf "r", "w"
fgets fputc "rb", "wb"


binary fread

size_t fread(void *p, size_t size, size_tn, FILE * f);
size_t fwrite(

int count = fread(&w, sizeof(int), 1, f);
count += fread(&h,...,1,f)

if(count ==2)
{


void fclose(FILE *f)

int feof(FILE *f)

dynamic structures?

struct Blokus
{
int clirn,
char* data;

}

typedef struct IntValue {
int value;
struct IntValue *next;
} IntValue;

IntValue *IntValue_create(int value)
{
  IntValue *iv = malloc(sizeof(IntValue));
  iv->value = value;
  iv->next = NULL;
  return iv;
}

void IntValue_destroy(IntValue *iv)
{
  free(iv);
}

IntValue *IntValueL_insertFront(IntValue *head, IntValue *node)
{
  node->next = head;
  return node;
}

void IntValueL_print(IntValue *head)
{
  whle (head!= NULL) {
      printf(" %d", head->value);
     head = head->next;
  }
  printf("\n");
}

int IntValueL_getCount(IntValue *head)
{
  int count = 0;
  while (head !=NULL){
     count++;
     head = head->next;
  }
  return count;
}
//put at back of list
IntValue *IntValueL_insertBack(IntValue *head, IntValue *node)
{
if(head ==NULL) {
node-> next = NULL;
return node;
}
IntValue *curr = head;
while (curr ->next != NULL)
{
curr = curr->next;
}
curr->next = node;
node -> next = NULL;


}
Reverse

IntValue *new_head = NULL;
  while(head !=NULL){
   IntValue *tmp = head;
   head = head->next;
   new_head = IntValueL_insertFront(new_head,tmp);
  }
  return new_head;
}
Find and delete?
int IntValueL_find(IntValue *head, int value)
{
//look for integery with value == to parameter being passed in
  while( head!=NULL)
  {
     if(head -> value ==value) {
      return head;
    }
    head = head-> next;
  }
  return NULL;
}

void IntValueL_delete

Master Struct
struct IntList

int main(int argc, char **argv)
{
   IntValue *head=NuLL;
   head = IntValueL_insertFront(head, IntValue_create(42));
   head = IntValueL_insertFront(head, IntValue_create(64));
   head = IntValueL_insertFront(head, IntValue_create(128));
   head = IntValueL_insertFront(head, IntValue_create(11));
   //looking for and find and print
   printf("Value %d is at point %p\n"
}




Back to ECE264, Spring 2011, Prof. Lu

Alumni Liaison

Basic linear algebra uncovers and clarifies very important geometry and algebra.

Dr. Paul Garrett