C :: Converting Simple Crc32 Program To Octave
May 1, 2014
I have been working on a simple crc32 program in octave and have been using a program already done in C as a guideline. I have been having some problems since octave and C simply do things differently. Right now i have a problem with right shifting.
unsigned int crc = -85
unsigned int x = (crc >> 1);
The resulting x will be 2147483605. I tried putting 0xFFFFFFFF instead of -85 and i got the same result.
If i put -85 for crc in octave, i get a small number -43 which looks more reasonable.
View 1 Replies
ADVERTISEMENT
Sep 27, 2013
Here is my code:
int main (int argc, char* argv[]) {
int x = atoi (argv[1]);
int y = atoi (argv[2]);
int z = atoi (argv[3]);
if (strcmp(argv[4], "Simple") == 0){
[Code ....
I need to convert the output of simple interest to float which is $5184.90 instead of $5180. how to go about it?
View 3 Replies
View Related
Feb 12, 2014
I would like to know how can I make a simple program .exe so that I don't have to open it through code blocks every time.
View 2 Replies
View Related
Feb 27, 2014
3. Write a program that reads a sequence of positive integers and prints out their sum, except that if the same number occurs several times consecutively, ignore all but the first. Assume an input of 0 marks the end of the input. For example, if the input is 3 8 5 5 4 9 1 1 1 1 8 0 then you should print 38 (i.e., ignore one of the 5's and three of the 1's).
View 5 Replies
View Related
Sep 28, 2013
I would to learn how could i calculate the offset of simple c program?
Lets say that I have that simple program:
Code:
#include <stdio.h>
int main() {
int x=1;
printf("x = %d", x);
return 0;
}
View 9 Replies
View Related
Aug 1, 2013
my program is printing out a random symbol afterwards , when trying to copy a sequence of chars into a new buffer.
Code:
#include <stdio.h>#include <stdlib.h>
int tokenCopy(char* dest, const char* src, int destSize);
int main() {
char buff[3];
int n = tokenCopy(buff, "This is a string", 3);
printf("%d '%s'
", n, buff);
[code]....
View 2 Replies
View Related
Dec 14, 2013
Code:
#include <stdio.h>
int main(){
double nc;
for (nc = 0; getchar() != EOF; ++nc)
;
printf("%.0f
", nc);
}
It works well and I am using ctrl-D as my EOF. Now I understand that C is not really a language for dealing with text, which is why I am learning it more in depth, my degree was in robotics, and I think C is definitely the best place to be for me. So this may just be a quirk, but if I type more than 10 characters, I get the right answer from the program, however, if I type less than 10, for the sake of argument I type Hello and then return, if I at that point do ctrl-D, I get the answer 6D?
The 6 is right 5 letters and a return character, but what is the D?
View 2 Replies
View Related
May 1, 2013
I'm trying to write a program that detects deadlock. Some of the code I already tested in an earlier stage but at this point when I run the code it somehow gets stuck. I believe that it has something to do with a negative integer value. Anyhow, the program should still work if a negative integer comes up. Here's my code so far.
Code:
#include <stdio.h>
#define FALSE 0
#define TRUE 1
int ALLOC[5][5], REQ[5][5], TOT_RES[5], process, resource, NUMB_RES=5, NUMB_PRO=5;
int TMP[5]={0}, AVAIL[5], CNTR=0, FIN[5]={FALSE}, FLAG;
}
[code]....
The program usually gets stuck after producing output displaying the "Available: " text. After that a list of tabbed numbers should appear, but it doesn't.
View 4 Replies
View Related
Mar 23, 2014
I decided to create a simple program to display a menu with options, while that is easy enough I had some difficulty when selecting an option that has options inside which also has an option again. While I had many issues in the past I'm finally finished with it and it works fine, but being new to programming and not knowing various other methods available.
Code:
//:::::::::::::::::::::Simple Menu Program::::::::::::::::
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#include <iostream>
#include <string>
//function prototypes
[Code] .....
View 1 Replies
View Related
Mar 6, 2015
The assignment is to write a program that statistically computes similarity of C syntax with another program; a same and a different. The one used here is in C language, it's called Battleship.cpp. The program must open a file and read line by line for keywords and then produce statistics. The reason my code is not running is the fopen function is failing and it goes to return -1. I am using MS Visual Studio 2013 and there are no compiler errors after turning off deprecation. I do see, however, this error UMEngx86.dll'. Cannot find or open the PDB file. The file being opened is in my source folder.
Code:
1
2
3
4
5
[code]....
View 4 Replies
View Related
Mar 25, 2014
My program allows a server and a client to chat over a socket. Currently I have to wait for one of them to type a message and press enter, before a message from the other person can be received.
Is there a simple way for messages to be received instantly - but not disturb any message that is being typed in?
View 2 Replies
View Related
Feb 22, 2012
I have created a simple basic program that uses sockets but it can only handle one connection, how do I make it so it handles multiple connections?
Server code:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
}
[code]...
View 5 Replies
View Related
Jul 22, 2014
I am trying to make a simple program for encrypting a char* with the XOR operator. The code compiles and links perfectly, but I get an Access violation runtime error:
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <fstream>
using namespace std;
int main(int argc, char** argv) {
[Code] .....
Text that I am inputting:
My username is memberfunction.
View 9 Replies
View Related
Apr 18, 2014
Write a program to do simple encryption and decryption. Encryption basically means to convert the message into unreadable form. In this assignment, it should be done by replacing each letter of a message with a different letter of the alphabet which is three positions further in the alphabet. Then, all the letters will be reversed. Decryption is the process of converting encrypted message back into its original message. Your program should use the following shifting method.
Note: You must use array.
#include <iostream>
#include <string>
using namespace std;
[Code].....
View 2 Replies
View Related
Feb 7, 2014
The program will ask for the user to enter a value for x, then compute the following polynomial: 3x^5 + 2x^4 - 5x^3 - x^2 + 7x - 6.However, when I double check it with my calculator I get a wrong answer for random values of x. To simplify my problem I'm using only integers.
Code:
#include <stdio.h>
int main(void)
{
int x, polynomial;
}
[code]...
View 5 Replies
View Related
Feb 21, 2014
I am new to C programming, I have been given an assignment to create a simple calculator by splitting the program in 3 files. It should have 2 .c files and 1 .h... I went through the internet extensively and could only come up with this.
main.c:
Code:
//Calculator main.c
#include <stdio.h>
#include <conio.h>
#include "Functions.h"
int main() {
float x = 0, y = 0;
int operation;
[Code]...
Functions.c
Code:
#include "Functions.h"
extern float x, y;
float addition (float a, float b) {
return a + b;
[Code]...
Functions.h
Code:
#ifndef FUNCTIONS_H_INCLUDED
#define FUNCTIONS_H_INCLUDED
float Sum(float a, float b);
float difference (float a, float b);
float remainder (float a, float b);
float product (float a, float b);
#endif
When I do a 'cl main.c' on the Developer Command window for VS2013, i get an error that reads :
main.obj
main.obj : error LNK2019: unresolved external symbol _difference referenced in function _main
main.obj : error LNK2019: unresolved external symbol _product referenced in function _main
main.obj : error LNK2019: unresolved external symbol _addition referenced in function _main
main.exe : fatal error LNK1120: 3 unresolved externals
View 5 Replies
View Related
Jan 17, 2014
This is the program below..can you spot the errors in it.. I am getting lots of errors...!!
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
struct student {
char name[10];
int rollnumber,result
float m1,m2,m3,total
[Code] .....
View 12 Replies
View Related
Nov 30, 2013
HelI have been tasked with creating a program which (1) takes in integer values from a user (until the user enters -1) and inputs these values into a linked list. This (2)original list is then to be printed out. The program then uses the algorithm "bubble sort" to (3)order the list in descending order before finally printing it out again.
I have managed to do this but I kind of cheated since I do not quite understand how to manipulate a linked list. What did was I took the values in the linked list and transferred them into an array and then did bubble sort on that array.how to do bubble sort on a linked list as well as how to print a linked list.
Code:
#include<stdio.h>#include<stdlib.h>
typedef struct node
{
int info;
struct node *link;
}Node, *NodePointer;
void printList (NodePointer head)
}
[code]...
View 4 Replies
View Related
Sep 26, 2013
I have to write a program that simulates a handheld gaming system. a system can have power toggled so its either on or off. when the system is on, its volume level can be raised or lowerd. a system has minimum volume level of zero and a maximum volume level of 10. a system stores games.
// simple game menu
//simulates a handheld gaming system
using namespace std;
class Game {
public:
Game(int GameNumber = 3, int volume = 10);
[Code] .....
View 1 Replies
View Related
Sep 20, 2014
I am not exactly sure how to do this and i keep running into problems. This is my code here that works.
Code:
#include<iostream>
using namespace std;
struct record {
double quiz1;
double quiz2;
double midyear, midyear_one;
[Code] .....
View 5 Replies
View Related
Apr 10, 2014
I'm having some problems with implementing an AI. It should be just a simple AI that follows player. Here is the code that I got so far:
(float)DirectionX = Circle->GetX() - AI->GetX();
(float)DirectionY = Circle->GetY() - AI->GetY();
(float)Hyp = sqrt(DirectionX * DirectionX + DirectionY * DirectionY);
DirectionX /= Hyp;
DirectionY /= Hyp;
x += DirectionX * 3;
y += DirectionY * 3;
This is what I got so far. It creates a vector in a direction I want to move, then just normalizes the vector. Simple as that. But I'm having 2 problems..
AI moves towards player only when Im at like the end of screen and the AI is on the other side, I must keep a certain distance for it to be able to move towards me. Basically, its not constantly moving towards the player. I also tried it with trig, using atan2 for angle and sin / cos for speed. Also didn't work, same result.
The other problem is when I want to add i.e 5 more AIs. For each new AI it creates, it makes a new update.. So, to kinda clear it up. If I'm in middle of the screen and an AI is spawned above me, it will move towards me. But when after that one, 2nd AI spawns beneath me, both 1st and 2nd AI move up. Basically, previous AIs take the update from last one that is created. For updating I'm using lists, objects and iters.
View 3 Replies
View Related
Jul 21, 2014
How do I play a simple mp3 through my mic. I plan on using this to just play annoying sounds through skype and games(on windows 7 btw).
View 6 Replies
View Related
Aug 8, 2013
I tried to write a simple program to calculate monthly yield, APR, and principle in various directions. Anyway, here's some code to get the APR from the principle and monthly yield. When I run it though, it spits 0 at me every time! What the problem is; the other functions work just fine and the code line for the APR calculation is just what it ought to be - I see neither a math nor tech problem here.
Here is the offending function:
Code:
void calculateAPR() {
int principle, monthlyYield, apr;
cout<<"
Please input the principle:";
cin>>principle;
cin.ignore();
[code]....
View 4 Replies
View Related
Jan 27, 2013
Code:
int i=5,j;
j=++i + ++i + ++i;
printf("%d",j); //22
i=5;
j=i++ + i++ + i++;
printf("%d",j); //19 Shall not it give 21 and 18 respectively?????
View 4 Replies
View Related
Oct 28, 2013
Just wondering about how to write extremely simple version of 'find' in C: It just lists the path names of the files in the specified directories and all subdirectories.For example,
Code:
$find_version .
./foo
./bar
./baz
./baz/other
[Code]....
View 6 Replies
View Related
Oct 5, 2013
I am writing a simple file parser for use in another project (for config file). The trickiest thing seems to be skipping unwanted characters (comments, spaces). It works partly, but after the second line of an inputed file processes only the first three characters.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TEXT_FILE "data.txt"
[code]....
NOTE: Currently I am just trying to process and remove unwanted data, the actual processing of extracted data should be much simpler.
View 6 Replies
View Related