C++ :: Creating Space Simulator Program For University

Aug 5, 2014

I'm creating a space simulator program for uni and I've got 3 errors that I just can't seem to fix.

View 10 Replies


ADVERTISEMENT

C++ :: Program That Can Count Space?

Jun 8, 2013

I was coding a program that can count space, new_line, and other characters in a paragraph, but it doesn't work.

#include <stdio.h>
int main(void)
{

[Code].....

View 1 Replies View Related

C :: Make Program Read Integer Until A Space?

May 23, 2013

I am trying to make my program read an integer until a space, namely ' ', is pressed, and then move on to the next command. However, all my attempts hitherto with both scanf() and getchar() have been to no avail. Every time it proceeds to the next command only upon pressing Enter, which is not quite what I want.

View 3 Replies View Related

C++ :: Program That Opens A File And Counts White Space Separated Words

May 17, 2013

Question is : Write a program that opens a file and counts the whitespace-separated words in that file.?

my answer is :

#include <iostream>
using namespace std;
#include <iostream>
#include <string>
#include <fstream>

int main() {
string filename = "Question 1.cpp"; // File name goes in here

[Code] ....

Now I am not sure if im suppose to get a msg saying : The file "Question 1.cpp" has 0 words.

im wondering is the question that im being asked, asking me to input a string of words and then the compiler when it builds and runs the program counts the word spaces.?

View 5 Replies View Related

C++ :: Bit Shifting - Cache Simulator

Apr 18, 2013

I'm attempting to make a cache simulator in C++. But I need to access individual bits in an integer to figure out where in my "cache" the writing actually gets done. I'm pretty new to bit shifting. Say I'm trying to access the the bits of the int 5, which are its "address". I'm simulating a direct mapped cache. I need to find its tag, the set it goes into, and which line. How do I use bit shifting to access the bits to acquire the tag, the index bits, offset bits, block number...all these pieces in order to actually find where I store it in the cache.

View 6 Replies View Related

C++ :: Gravity Simulator Implementation

Jul 9, 2013

I've been working on creating a simulator to crash two galaxies together as part of a project to stress test a CUDA super computer. I've got a long way to go and am currently just working on correctly simulating n-body gravity functions. First I will use this to simulate the cores of the galaxies (the black holes) and eventually the stars.

So long story short I'm working on the beginnings of a gravity simulator. At this point I found some basic code that works well but doesn't quite give the effect I'm looking for.

The code below only pulls each object towards each other like a spring faster and faster until they shoot off into infinity. I try to give one of my bodies an initial velocity to get it to orbit another, but it always just shoots straight at the other body. I'm thinking I need to factor in inertia so that the initial velocity doesn't just get calculated away really fast by the other calculations.

I'm really looking for a bit of direction to get a real gravity simulator with orbits and such working right so eventually I can scale it up to a galaxy, throw in 100B stars and let the CUDA run for a month..

Code:
void update_galaxies(GLdouble elapsedTime) {
//Calculate gravity simulations
GLdouble r1, r2, r3;
r1 = r2 = r3 = 0.0;

for(unsigned int i = 0; i < galaxies.size(); i++)

[Code] ....

As you can see, I'm calculating all the bodies in a vector called "galaxies" with each other, and doing a basic gravity calculation to it. The update_position function simply takes the calculated acceleration and uses it to calculate the velocity and position based on the "elapsedTime".

I think I need to use the Varlet or Runge-Kutta integration methods, after doing a bit more research.

View 9 Replies View Related

C :: Cache Simulator - Bit Shifting

Apr 21, 2013

I'm attempting to make a cache simulator in C++. But I need to access individual bits in an integer to figure out where in my "cache" the writing actually gets done. I'm pretty new to bit shifting. Say I'm trying to access the the bits of the int 5, which are its "address". I'm simulating a direct mapped cache. I need to find its tag, the set it goes into, and which line. How do I use bit shifting to access the bits to aquire the tag, the index bits, offset bits, block number...all these pieces in order to actually find where I store it in the cache. I need to break the bits up into 3 sections: tag, set index, and block index. I think I can figure out the set and block index sizes based on the values passed in. The tag bits are just the remaining ones. And I'm hard coding values such as cache size (C) - 1024, number of physical address bits (m) - 32, block size (B) - 2, number of lines per set (E) - 1 (again, directly mapped cache). How would this look? I'll be using unsigned longs, so it can handle up to 64 bits.

View 3 Replies View Related

C :: Secure Entry Keypad Simulator

Feb 15, 2015

We've been tasked write a code which would mimic a secure entry keypad.. Only recognising the digits 0-9 for the passcode, and non-numerics S (start again) C (clear last digit) and E (enter) for the control. All other key strokes are to be ignored.

The passcode has to be <10 digits and represented on the screen by "****", with any keystrokes >10 ignored.
The valid passcode being 4 digits (1234).

With 3 attempts to get the correct pass code, after each fail attempt as please try again message show, where after the 3rd attempt a specific message is displayed and an alarm sounds..

View 13 Replies View Related

C++ :: Dice Simulator - Floats Rounding Up

Oct 28, 2013

I made this dice simulator which basically throws the dice 1 million times and outputs the frequency and percentage average for each side (1 to 6).

Everything is working fine, except my averages (floats) seem to be rounding up, causing 4% being "unassigned" at the end of the million rolls. I'm outputting with a setprecision of 2, but I only get 0's and no fractional numbers.

View 5 Replies View Related

C/C++ :: Simulator To Implement Populations For Given Number Of Months?

May 18, 2013

How can i implement a simulator that computes the populations for a given number of months for all sectors.

View 1 Replies View Related

C++ :: Error Handling - Enigma Cipher Simulator

Jan 4, 2014

I finished my Enigma cipher simulator...how should I write the error handling code? Should I throw an exception in main, or in the Enigma ctor and Encrypt() fn when the user enters a non-alphanumeric character?

Rotor.hpp

Code:
#ifndef ROTOR_HPP
#define ROTOR_HPP
class Rotor {
public:
Rotor(char pos='A');
Rotor(const Rotor & rhs);
Rotor& operator=(const Rotor& rhs);

[Code] ....

Output

Code:
Enter rotor settings:
ABCDEFGHIJ
Enter cleartext:
HELLO WORLD
Ciphertext:
0O258 SGY5V

View 3 Replies View Related

C++ :: Airline Reservation Simulator - Binary File Errors

Aug 11, 2014

For a big project for school I have to make an airline reservation simulator but I have run into a problem. I want to save the the flight code and its location in a binary file so that I can obtain a code according to the location but this happens:

[URL] ... (link to current output and expected output)

Here is the source class

class file {
private:
char code[8];
char from[20];
public:
void input();

[Code] ....

View 4 Replies View Related

C++ :: Battle Simulator - Save / Load Functions Not Working

Oct 16, 2013

I've been working on a battle simulator, and using it as a learning experience. So far, I've been able to debug the program, and learn some stuff, and it's been running smoothly. It's still runnable, but I've been trying to make it so the player can save his character, and continue the game later. However, I'm not sure whether it's the save or load function that's not working, because even if i save to a txt file, it's just a bunch of random characters. I don't know if that means it's not saving correctly, or if it's just supposed to be like that. Anyway, here are the two functions I'm speaking of:

Code:
void Game::saveGame(Character &player) {
std::ofstream saveFile("save.bin", ios::binary);
saveFile.write((char *)&player, sizeof(player));
saveFile.close();

[Code] .....

My program is in multiple files, so I can't really post the whole code easily, but I can upload or something if I really need to.

View 14 Replies View Related

C++ :: Highway Simulator - Cars Move From Start Point To Quit At End

Jun 12, 2013

i want to draw a highway, this simulator must not be graphical (must draw by "|" and "-" and...) . this highway include 3 type of car,

1- heavy
2-light heavy
3-light, t

These cars move from start point to quit at end of highway, highway must be object (programmed by class), and have 200 columns and 4 raw, it must be horizontal... . the cars speed are different,

speed =1,2,3; length=1,2,3;

View 3 Replies View Related

C++ :: Creating Do-While Loop In Program

Apr 28, 2014

I need starting a do-while loop in my program that runs up to 10 time that asks the user to enter up to 10 scores, which include the slope and rating for the course, and calculates the handicap for each score.

Here's what I have so far:

Code:
{
//This program calculates a golfers handicap.
#include <iostream>
#include <string>
using namespace std;

[Code] ....

View 1 Replies View Related

C :: Creating Border Around Program

Mar 6, 2015

I am trying to create a border around my program. It looks like this: . I had to read a file in, which is in the attachment and produce the desired output in the image. I have produced the desired output, but without the border.

Here is my code thus far:

insert Code:
#include<stdio.h>
#include<Windows.h>

#define HEIGHT 21
#define WIDTH 78

int map[HEIGHT][WIDTH];
int i = 0, j = 0;

[Code] ....

View 2 Replies View Related

Visual C++ :: Creating DLL From Program

Jan 15, 2013

I wanna create a DLL from my C++ program. My output of my C++ program is a text file called Centre_Cartouche.txt My output is two text files called brd.txt and sym.txt

At the beginning my program was just a main which contains all development (Main.cpp). Now I created function (in _Cartouche.h and _Cartouche.cpp).

My debugger tell me that the simulation works. But my file Centre_Cartouche.txt is not create.

_Cartouche.cpp_Cartou.hbrd.txtsym.txt

View 1 Replies View Related

C++ :: Creating Menu Program Using Only If And While For En Do Loops

Mar 13, 2014

I just started learning the basics of programming. While encountering one of the practice problems in the book by Alex Allain I got a little confused. The question is as follows:

Write a menu program that lets the user select from a list of options, and if the input is not one of the options, reprint the list.

The author assumes you can answer this question only using if statements and/or loops (while, for and do).

This is the code I've written thus far:

Code: #include <iostream>
using namespace std;
int main()
{
int option;
char reset;

[Code] ....

For some reason, the nested while loop keeps repeating even when you input a valid option (1, 2 or 3). I can't seem to figure out why this happens.

View 4 Replies View Related

C# :: Creating Encryption Program Like TrueCrypt?

Feb 8, 2014

Is it possible to encrypt a folder and put it in a file container. Would I need to store the header key and other stuff my self or do the encryption methods take care of it? I am just getting into file input/output. I am just looking to make a simple console based one.

View 5 Replies View Related

C++ :: Creating A Program That Encodes And Decodes A Message?

Sep 10, 2014

I am starting this project on how to encode and decode messages that are inputted, how to start this?

View 4 Replies View Related

C++ :: Creating Ability To Read Pages Into Program

Feb 17, 2014

I am working on writing a game that progresses from one "page" to the next. However, with the knowledge and experience I have right now I am only able to hardcode the "Pages" into the source code. I would like to learn how to put the pages into another file "default.pages" and have the program read the file and input the information into itself after I have compiled it. Then, if I change the pages file I simply have to restart the program instead of recompiling all of it. Someone said I should use XML and input it into an object and use that object, but I'm not sure how to do that yet.

I have 3 files right now:

main.cpp, pages.cpp, and pages.h.
//MAIN//

#include <iostream>
#include <string>
#include <fstream>
#include "pages.h"
using namespace std;
const Page gamePages[] = {};

[Code] ....

View 9 Replies View Related

Visual C++ :: Creating DLL That Will Be Used As Plugin In External Program Using MFC

Jan 30, 2013

This is the problem in detail:

I have a VC++ project to create a DLL that will be used as a Plug-in in an external programm. This DLL uses some MFC functions. The initial configuration of the project was:

-Use of MFC: Use MFC in a Static Library

-Common Language Runtime support: No Common Language Runtime support

-Runtime Library: Multi-threaded Debug (/MTd)

This configuration worked fine, there were no compilation errors and the resulting DLL worked correctly.

The problem came when it was necessary to add to the DLL some functions of .NET, using the namespace System and similar. To do that, I had to change the Common Language Runtime support, to Common Language Runtime Support (/clr). Then, when I tried to compile, I got this message:

'/MTd' and '/clr' command-line options are incompatible

So I changed the Runtime Library to Multi-threaded Debug DLL (/MDd). Then I got this error message:

Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version

So I also changed the Use of MFC to Use MFC in a Shared DLL.

After this, the compilation was correct. Then logically the size of the generated DLL is smaller, but this new DLL does not work correctly, the external program in which this DLL is used crashes.

I don't know what to do to fix the problem. Maybe I need to add some other DLLs or files to the directory where the DLL is located, where the external program uses it. But I would prefer to include a single DLL file, but this seems to be incompatible with the use of .NET functionality.

View 11 Replies View Related

C++ :: Creating A Random Number Generator Program?

Aug 9, 2012

I'm trying to create a program that creates random numbers. I looked through some examples and this is what I came up with. The time identifier seems to be undefined yet I see no reason it is undefined.

Code:
#include "stdafx.h"
#include <iostream>
using namespace std;
int main() {
//Re-seed the random-number generator
time_t now;

[code]...

here's my error code..

1>------ Build started: Project: bake, Configuration: Debug Win32 ------
1> bake.cpp
1>c:usersjonbecherdocumentsvisual studio 2012projectsakeakeake.cpp(8): error C3861: 'time': identifier not found
1>c:usersjonbecherdocumentsvisual studio 2012projectsakeakeake.cpp(9): warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

View 2 Replies View Related

C :: Creating Program That Can Pick Words In A String Or Array

Apr 24, 2013

Creating a C program that can pick words in a string or array and save it in different location, later combine everything in one string or array. It will be using simple programming C code. For example (arrays, pointer) but not interrupts or other string functions.

In a sentence like this:
Size= 70
$--GSV,x,x,x,x,x,x,x,...*hh $--GGA,hhmmss.ss,llll.ll,a,yyyyy.yy,b,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx*hh $--GLC,xxxx,x.x,a,x.x,a,x.x,a.x,x,a,x.x,a,x.x,a*hh $--GSA,a,a,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x.x,x.x,x.x*hh

The program must capture the $--GGA string then extract from this string:

1) hhmmss.ss
2) IIII.II
3) a (if a = to N or S replace N or S with + or - respectively )
4) yyyyy.yy 5) b (if b = to E or W replace E or W with + or - respectively )

Save them in an array and display as well. After all the saving, the program should combine them to one string. That the final output.

View 7 Replies View Related

C :: Creating Simple Calculator By Splitting The Program In 3 Files

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

C++ :: Creating Infix To Postfix Program Through Inherited Class

Apr 25, 2014

I have the following problem on my C++ Program and I am not sure why it is not working. I am creating a infix to postfix program through an inherited class which I am not sure it is working.

#include <iostream>
#include <stack>
using namespace std;

int in_stack_Priority(char a){
if(a == '*' || a == '/')
return 2;

[Code] .....

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved