Off Topic > Off Topic

Programming Megathread

Pages: << < (32/241) > >>

ZSNO:


--- Quote from: McJob on November 02, 2015, 12:14:09 PM ---forget me absolutely and unfathomably senseless.

The method I'm using for "source control" (lol) is basically daily folders commited to a dropbox folder, a USB folder and a portable HDD folder. And when I woke up this morning, I looked at the Unity jump list; I had been working directly out of one of my backup folders instead of making a working copy on the desktop like I normally do, and then I copy/pasted a version on the desktop over all the other versions.

Half a week of work lost.

--- End quote ---
This is why you should use software to do it for you.
Might as well start now

McJob:


--- Quote from: ZSNO on November 02, 2015, 01:12:27 PM ---This is why you should use software to do it for you.
Might as well start now

--- End quote ---
There's like 3 weeks of this project left. Not going to bother right now.

Foxscotch:


--- Quote from: McJob on November 02, 2015, 01:21:57 PM ---There's like 3 weeks of this project left. Not going to bother right now.

--- End quote ---
what if you mess up again

Otis Da HousKat:

Your school should already have servers set up for the common source control stuff like git and mercurial. Spend an hour getting it up and running to avoid losing days worth of work.

Kochieboy:

Ugh, alright, time for more buggy code troubleshooting.

So I wrote this up, compiled just fine and for some reason it will not break out of the first for loop in main()


/*
   Program written to verify a 12 digit code from a barcode by comparing the code's last digit to the check digit
   Written by Silico Deoxy on November 7, 2015
   Version: 1.0
   Language: C (gcc target)
*/

#include <stdio.h>

#define SIZE 12

void scan(int upc[]);
int checkodd(int upc[]);
int checkeven(int upc[]);

int main(void){

   int upc[SIZE],
      i,
      f,
       sum,
       check;
   i = 0;
   do{
      printf("Please enter each digit of the UPC\n");
      scanf("%d", &f);
      upc = f;
      printf("%d\n", i);
      i++;
   }
   while(i<12);
   printf("Debug");
   sum = checkodd(upc);
   sum = sum + checkeven(upc);
   if(sum % 10 == 0)
      check = 0;
   else
      check = 10 - (sum % 10);
   if(upc[11] == check)
      printf("This UPC is correct!");
   else
      printf("This UPC is incorrect!");
   return 0;
 
}

int checkodd(int upc[]){

   printf("Checking odds");
   int p,
       sum;
   sum = 0;
   for(p=0;p<12;p+2)
      sum = upc[p] + sum;
   sum = sum * 3;
   return sum;
}

int checkeven(int upc[]){

   printf("Checking evens");
   int p,
       sum;
   sum = 0;
   for(p=1;p<12;p+2)
      sum = upc[p] + sum;
   return sum;

}


Can anyone find the problem?

Pages: << < (32/241) > >>

Go to full version