C++ :: Using Outfile To Write Name?
Sep 4, 2013
I am trying to display my name using outfile vs. cout and I get errors I don't know how to fix. Here is the code:
//This program will calculate the monthly payment, the total amount paid back over the entire life of the loan,
// and the total interest paid over the life of the loan.
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int main() {
ofstream outfile;
[code]....
And here are my errors:
1>z:csci207program1practice.cpp(13): error C2297: '<<' : illegal, right operand has type 'const char [16]'
1>z:csci207program1practice.cpp(13): warning C4552: '<<' : operator has no effect; expected operator with side-effect
View 1 Replies
ADVERTISEMENT
Aug 5, 2013
I have created a game that functions correctly, however, for balancing and future changes, I would like to record results .txt document (its 1v1 btw). I already have code to determine who won and what I am looking for is some way to keep track of different match-ups for the different characters. Im looking for something like this:
loser
Winner char1 char2 char3
char1 3 2 5
char2 2 5 4
char3 8 1 2
the numbers are the amounts of wins a given character has over another character. I'm looking for code to open the .txt file and add 1 to the respective win total so I can do balance changes and such.
View 1 Replies
View Related
Jul 30, 2013
How to get a txt Outfile to display a Checksum.
Code:
ChecksumFileDisplay = fopen(ChecksumFileDisplayPath, "r");
fprintf(ChecksumFileDisplay, BigEndianChecksum);
That's what I have but it doesn't like the fprintf function because BigEndianChecksum is an unsigned int and it wants a pointer to a const char. Is there a function similar to this that will display an 8 digit integer in a txt outfile?
View 1 Replies
View Related
Jul 8, 2014
My assignment asks me to read inputs from a certain file which has data as shown below:
else if (menu == 3) {
ofstream outFile("output.txt");
Shares share1 = shareList.get(0);
double price1 = share1.getTradePrice();
time24 time1 = share1.getT();
[Code] ....
View 1 Replies
View Related
Jul 25, 2013
I know I need <math.h> and I know how to write tan(10) or whatever I need. However I need angles, like 100 / tan10 = 567.13. The 10 is degrees.
I am doing a fun project now that I feel more confident. However my textbook only shows me how to use the math library and only shows a few trig functions.
I am applying Trigonometric Functions to see if a car is speeding.
View 3 Replies
View Related
Aug 27, 2013
For instance Code: int counter;
counter =0;
FILE *pfile;
pfile= fopen("g:myprog.txt" "w");
while (counter >100)
{ fprintf (case counter{something})}; how do I do this?
View 11 Replies
View Related
Nov 12, 2014
I can only write one value to file:
get all, say for example barcode
char* bst:: get_bar(hwareItem*& root){
while(root!=NULL){
get_bar(root->left);
[Code]...
gets only one value depending on traversal orderI wish to get all values of BST
View 1 Replies
View Related
Jun 10, 2014
i'm using TryParse to convert 5 in string to 5 int but i want to give the possibility to the user to write five not 5.
View 5 Replies
View Related
Mar 28, 2015
I was following a c# book to write a WPF with a textbox. When the textbox is selected(got focus) with keyboard or mouse, it will select all text in it. I followed the book and wrote this:
private void TextBox1_GotFocus(object sender, RoutedEventArgs e) {
TextBox1.SelectAll();
} private void TextBox1_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) {
var control = sender as TextBox;
[Code] ....
The book said having "e.Handled = true" is to stop the event in order to prevent the cursor being positioned on somewhere of the text instead of selecting all text. From my understanding, "e.Handled = true" is for stopping routed events. Is this means that something will run if "e.Handled = true" is not there? If yes, then what is it?
View 2 Replies
View Related
Sep 23, 2014
i am having some trouble with a piece of code im writing for class.
here is my code
for (j=7; j>=0; --j){
putchar((name[i] IF_STATEMENT);
write(1, " ", 1);
I am trying to use write to format my output so that it looks like this
0 0 0 0 0 0 0 0
The formatting works fine when i use printf("%s", " "); in place of write but for some reason when i use write the format comes out like this
00000000
I dont understand why this is happening. Does write always work outside of a for loop or something?
View 6 Replies
View Related
Jan 22, 2013
#include <iostream.h>
#include <conio.h>
int main ()
{
cout << "Hello World";
getch();
return 0;
}
In the above code, why is it necessary to write getch() and return 0? What is their purpose?
View 7 Replies
View Related
Apr 26, 2013
so i have this dll with a DBTProc, whenever a window gets created i want to write something in a log file. Now everytime I run it it adds three times the text in this log file, but then it does nothing anymore. I do hear a beep everytime a window get created so it doesn't actually open my file to write in
code:
LRESULT CALLBACK CBTProc(int code, WPARAM wParam, LPARAM lParam)
{
if (code < 0)
{
[Code].....
View 7 Replies
View Related
Apr 13, 2014
I just started by defining a stack class (stackDouble). I need to write a program that accepts an infix calculator expression, with the following operators (**, exponentiation, /, division, and, -, subtraction. The operator precedence is exponent, division, and subtraction.I need to use a stack of doubles and a stack of strings, of which I can write two classes, or write a single stack template. The user will input the expression just via cin, and there will be a # before every number, a ! before each operator, and a . at the end of the expression. '#', '!', or '.' can be input into a char variable, numbers into a double variable and operators into a string variable.
For example, the following would output 6:
# 3 ! / # 2 ! / # .5 ! ** # 2 .
As stated above, I already made up a stackDouble class. What would I need to do to create the other class (I don't think I want to do it with a template)?
Code:
#include <iostream>
#include <string>
using namespace std;
class stackDouble{
[code]....
View 2 Replies
View Related
Mar 3, 2013
How can I erase the data stored in /tmp/a.txt after every run of this code?
Code:
#include <stdio.h> // IO operations
#include <unistd.h> //for pid, ppid, fork functions
#include <sys/types.h> //for pid_t type, kill function
#include <stdlib.h> //for exit function
#include <signal.h> //for kill function
#include <sys/types.h>
#include <sys/stat.h>
[Code]...
View 3 Replies
View Related
Sep 22, 2014
How would one write 3^i without using .math? (i being numbers 0-9)
More specifically, this is what I have:
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int x, n, answer1, first;
x = 3;
n = 10;
first = 1;
[Code]....
And this is what I want it to produce:
1 0 1.0
3 1 0.333333343
9 2 0.111111112
27 3 0.037037037
81 4 0.012345679
243 5 0.004115226
729 6 0.001371742
2187 7 0.000457247
6561 8 0.000152416
19683 9 0.000050805
I believe I am only having troubles with the first column,
View 10 Replies
View Related
Jun 30, 2013
How can i upgrade my program I want to input a octal and binary number and convert them in base 2, 8, 10, 16..
how can I write the scanf with the right parameter in it??
Code:
scanf ("%x",&i); Code: #include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int main() {
int i;
char buffer [33];
[Code] .....
View 5 Replies
View Related
May 10, 2013
I have a batch of .pdf files (~1000) with names 001.pdf 002.pdf ...etc. Still pretty new to C, but would it be possible to write a program that would open a PDF, prompt a new name from user, and when entered, close the .pdf and open the next one in the list?
View 14 Replies
View Related
Dec 22, 2013
My program needs to receive data continuously from one process and the received data is read continuously by another process.But when I am trying to create a pipe using mknod on fat32 file system in linux , it throws an error saying "mknod: operation not permitted".
View 3 Replies
View Related
Jul 22, 2014
write an algorithm using stack to determine if an input of string is in the form xCy where y is the reverse of x.x and y are strings of A and B. eg : AABACABAA
View 8 Replies
View Related
Oct 31, 2013
My problem is :
Code: numbers[10]={25,27,17,19,47,3,98,5,124,10};
You write a program at do below processes for above array.
You want a number 1 between 10 at user.
if user enter N value,program write to screen lowest N. number at array. For example user enter 2,program write to screen lowest secondary number of 5 value at array or user enter 10 value,program write to screen maximum number of 124 value at array.
But write the program with don't use sorting algorithm.
View 6 Replies
View Related
Aug 14, 2013
I need to develop a tool to compare geometric structure of point cloud from scanned objects with their CAD model. The CAD model is stored in step file. So how could I extract geometric information from step file? I am totally new for CAD.
View 6 Replies
View Related
Jan 16, 2013
I am trying to write to external file in GCC. So far I can get to this:
#include <iostream>;
#include <fstream.h>;
using namespace std;
int stream (int argc, char* const argv[]) {
ifstream in ("mcp.strings");
[Code] ....
I need to know if I am using the correct method to choose file name. And how to set a script(double) variable to print input text or choose an on/off (0|1) input to be written to a text file.
Any links to flags (i.e. pointers and how to use them).
View 2 Replies
View Related
Sep 27, 2013
How do you write a default constructor?I need to use a default constructor that will initialize the data members:
- salesPerson to “Unknown”
- noOfWeek to 13
- amount to point to an array of thirteen 0.00s.
This is my weeklysales class
class WeeklySales {
char* salesPerson;
double* amount; // Pointer to an array
int noOfWeek; // Size of the array
};
Here's my attempted code:
//default constructor
WeeklySales (){
salesPerson="Unknown";
noOfWeek = 13;
amount = 0.00;
}
View 9 Replies
View Related
Apr 21, 2013
I want to write a bootable c/c++ Hello World. How can i do that?
View 2 Replies
View Related
Feb 14, 2013
I need to write a data input for one of my class assignment. Would this be considered a data loop?
while (cin >> number)
View 4 Replies
View Related
Nov 25, 2014
I have been learning Direct3D for a while now (DX11), and I ran into a bit of a dead end. I have Frank Luna's book on D3D programming, but I feel like I could find a better tutorial out there. I am at the point of writing the vertex shader (the first one he goes over)
Currently, I am using .fx files to write the shaders. Is that right?
View 10 Replies
View Related