This project is a Atmega 2560 connected to a serial GLCD screen.I've got serial communication working perfectly.Now as you can see I wrote a function that sends 1 single character to the UDR1.I wrote a function that uses this first function for sending entire words (strings).All of this works great.
Next challenge is writing a "int byte" to the GLCD screen.In this case the variable "voltage" has a value of 100.I'd like to write that 100 to the serial display via the uart.But whenever I do this the screen reads this 100 as a ascii decimal number... (= d)
I've tried things like
LCD_PrintStr("voltage"); (Result: The word voltage shows up on the screen)
LCD_Write(voltage); (Result: write ascii letter for dec 100 (= d ))
I'm using maps and writing files for the first time and I get a crazy compiler error when I try to compile the following code.
//map is named schedules // saveSchedule() is a member of the Schedule class that writes a vector of objects to disk, or is supposed to ofstream newFile("sched.txt"); map<string,Schedule>::iterator in;
I'm writing a program using Huffman algorithm to compress text file. I have tested my program by just printing the printing ASCII character to file and it worked fine. However, now I have to implement using bits and my program doesn't work. It seems like I'm not reading or writing the right bits. Here is the result of my testing:In the input file I put abc the input file to compress it. Then I uncompress it the out out is aaa. Below is a snippet of how I read and write bits
Code: class BitInput { istream& in; // the istream to delegate to char buf; // the buffer of bits int nbits; public:
I have a question about an issue I am having on my final project. Within my ItemEntry.cs form, I am trying to get the application to append the already existing .txt file, rather than prompt the user to replace it. I can't seem to get the StreamWriter and FileStream to allow the user to write to the file.
Code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq;
I am trying to write a structure to a file. Example say the structure has two variables x and y . I want to write a function which modifies these variables and stores the modified version on a file. Such that next time I call the function . it has the values from the previous write. Here's an example of my code .
// do some calculations. fwrite(mystruct, sizeof(MYSTRUCT), 1, fp); fclose(fp)
//return some value }
The problem is that each time I run the program it shows the initialized value of the variables and not the value from last write. I guess the write isn't successful because when I open in w+ mode. i get the error file could not be opened and then i have to delete the file and re create it....
Code: #include<stdio.h> #include<string.h> #define a 9 #define b 9 #define c 3 int main() {
[Code] .....
In practice section there was a challenge to print up numbers in letters up to billion including negatives I didn't look at the solution and came up with this but it is getting difficult after this point....
I have a text file containing 500 signed decimal numbers. My task is to read each entry and convert into a 16-bit 2's complement representation (binary number) and write into the another text file.
Name: Mary Smith Exam 1: 65 Exam 2: 79.1234 Exam 3: 70.24
Becomes something like this in the output file:
Name: Parker, Peter Average Score: 92.28 Grade: A
Name: Smith, Mary Average Score: 71.45 Grade: C
I know I'm supposed to read the whole file, but I'm getting really confused on how to take the name of each student separately without recording Exam 1, 2, and 3. I'll be able to do the average score and grade on my own.
Is there a way to read and write to the same file?
I'm writing a game program and I want to save the score at the end of the game to a txt file. The txt file already contains other game scores. How do I store the score without overwriting the previous scores.
I have to make a program that asks for your username (any)to register it. When you type it it will say something. I want to create a txt file also. so this is what I have:
#include <iostream> #include <fstream> using namespace std; int main() { int a; { ofstream myfile;
[Code] ....
now, how can I use the cout again to print something "Welcome to the program..."?
I want to write a program in cpp which will create a file and write some classes into it so that whenever i will execute that program i will have the auto generated file. How to do it....
I'm writing a program using Huffman algorithm to compress text file. I have tested my program by just printing the printing ASCII character to file and it worked fine. However, now I have to implement using bits and my program doesn't work. It seems like I'm not reading or writing the right bits. Here is the result of my testing:In the input file I put abc the input file to compress it. Then I uncompress it the out out is aaa. Below is a snippet of how I read and write bits
public:
BitInputStream(istream& s) : in(s), buf(0), bufi(8) { } /** Read the next bit from the bit buffer. * Return the bit read as the least significant bit of an int. */ int readBit(){ int i; if(nbits == 8){ buf = in.get();
I'm messing around with reading and writing files. The first file creates a small txt file. Simple enough
#include <iostream> #include <fstream> #include <string> using namespace std; int main(){ string name; string desc;
[Code] ....
It does what it should. It creates a text file "items.txt" .... It reads as such:
dagger,a dagger,15,10,0,1,3,1,0,0,0,1,0,0,0,0,0,1
The second file is meant to read the file and place the data back into the variables. This happens, but the data crams itself into the first variable, and the rest of them collect the trash that's in memory.
#include <iostream> #include <fstream> #include <string> using namespace std; int main() { string name,desc;
[Code ....
I need to get "dagger" into name, "a dagger" into description, and each value with their perspective variable. I'm sure I need some type of "separator". Hopefully I can use the comma. Before it's over, I will have about a hundred items that will need to be read into a class of items.
I have the following code to write to an error log that I send to a client. It correctly logs all of the errors but for some reason it produces it all out on 1 line and it's not removing the last comma. You can see on line 14 I am calling writeline instead of write and I'm passing a false to the formatAsQCD method that should cause it not to place the comma.
Returned Output (personal info blanked out) "103066139999","5000052166-00","XXXX","XXXX","2015-01-24","XXXX","","XXXX","XX","XXXXX","XXXX","20150407","Member has no provider choices that match the necessary criteria","102254726799","5000075745-00","XXXX","XXXX","2015-02-26","XXXX","","XXXX","XX","XXXXX","XXXX","20150407","Member has no provider choices that match the necessary criteria",
Expected Output (personal info blanked out) "103066139999","5000052166-00","XXXX","XXXX","2015-01-24","XXXX","","XXXX","XX","XXXXX","XXXX","20150407","Member has no provider choices that match the necessary criteria" "102254726799","5000075745-00","XXXX","XXXX","2015-02-26","XXXX","","XXXX","XX","XXXXX","XXXX","20150407","Member has no provider choices that match the necessary criteria"
I've got an issue with my code; whenever I add the " " for a newline, a newline is not actually printed onto the file.
Here's my code:
/* Description: Lists all the files & other directories in the directory passed through argv. */
/* Importing the required headers. Dirent.h for the dirent struct. Stdio.h for printf. Conio.h for File input/output. */
#include <dirent.h> #include <stdio.h> #include <conio.h> int main ( int argc, char *argv[] ) { // Checking that the user has given the correct number of arguments.
[Code] .....
The solutions I've tried are:
Trying to add the ASCII character for a carriage return (13) and newline (10), but it didn't work.Using fputs() and fprintf() - both mentioned in the code.
I want to do a basic thing but for some strange reason there is something not working.
I need to write to a file but I'm handling all the code in a callback function, which in turn is declared in a class. Here is the architecture of my code:
Code: int main (int argc, char **argv) { ImageConverter Aclass; while(1); //infinite loop return 0;
[Code] ....
But this doesn't work, the file gets created but it allways overwrites itself which is not what I need to do.
What I am doing wrong? Is it because i am constantly declaring outfile?
program that I am working on. I want to use fgets() in my program so I could handle multiple words from a text(to be able to handle spaces). I get a weird result when running the program.
I need writing a macro that would return true/false (1/0) )value. I want to check if a certain element exists in the array. The macro will accept array, its size, and the value to be compared, and must return yes or no. Here is the code that I have written:
Code: #define EXISTS(T, a, n, val) do { char ret=0; T *a_ = (a); size_t n_ = (n); for (; n_ > 0; --n_, ++a_){ ret = (*a_ == val); } } while(0)