I am building a template for CodeBlocks, which pre-write some includes, the main skull and a header.
This header looks like that :
/**
* @Author Me
* @Description Brief description
* @Date ??
*/
I would like to put the current Date, just after the line @Date, is-it possible ? And if yes, it-is possible to put a field @FileName which copy the filename into the comment ?
class DataBase { // Change the connection path here to your own version of the database public SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)v11.0;AttachDbFilename=|DataDirectory|UberDatabase.mdf;Integrated Security=True;"); public DataBase() { } }
And in the same namespace as this class I have a form that calls it like so:
DataBase dBase = new DataBase(); SqlCommand trythis = new SqlCommand("Register", dBase.con);
However, I'm getting the field initializer error on dBase.con. I'm not sure why, but when I call the database from another file (program.cs) it works fine this way.
How can I check for an invalid date when I run the program? I am trying to enter a conditional statement that checks for a valid or invalid date.
Programing Question: Write a program that inputs a date (e.g., July 4, 2008) and outputs the day of the week that corresponds to that date. Here is what I Have. The program runs. I need it to loop around.
#include <iostream> using namespace std; const int JANUARY = 1; const int FEBRUARY = 2; const int MARCH = 3; const int APRIL = 4;
So I have a programming assignment which is for getting a user input in the format of m/d/yyyy. This is stored as d/m/yyyy. I have been able to code all the rest of the requirements of the program but the thing that is giving me trouble is this. The year is allowed to go from 1-3000. The format of the displayed date is:
a zero-filled, two-digit day number, a dash, full name of month, a dash, zero-filled, four-digit year.
I am able to use a switch statement in order to get my name of the month. What I am struggling to figure out is the whole zero filled two digit day and zero filled four digit year. From the way the input is store it appears to me that it will be stored as yyyy which means if you were to enter 0001 for year 1 then it should output it as that (this is an assumption based on format). What I don't get is that the day is entered and stored as d which means if you put in 12 how would it be stored. However if you put in 6 to print the output I would need to add a zero and I dont know how to do that either.
Here is the code for getting the input. The function must stay formated this way as per the instructor. The / is stored but ignored hence the char for second and fourth since / is a char
Code: void getDate (int& day, int& month, int& year){ char second; char fourth; cout << "Please enter a date in the format of m/d/yyyy" << endl; cin >> month >> second >> day >>fourth >> year; }
In my WinForm, Our client insists to use Textbox instead of DateTimePicker field, and they want to input in ddmmyy format.
Using Visual Studio 2010 C# 4.0.
PC date time setting: GMT +08:00 dd-MMM-yy.
Assumed today date is 291014 (29-Oct-14).
CodeBehind:
DateTime inputDate; // the WinForm allows user to input date not earlier than 2 years before today date and not more than 1 months from today date too. //Assumed I input date as 261014 (26-Oct-14) if(DateTime.TryParseExact(input, "ddMMyy", new System.Globalization.CultureInfo("en-US"), System.Globalization.DateTimeStyles.None, out inputDate)) { DateTime minDate = DateTime.Now.AddMonths(-24);//Assumed it is 29-Nov-14 DateTime maxDate = DateTime.Now.AddMonths(1);//Assumed it is 29-Oct-12
I tried many methods but none works (I have checked many threads/forums also).
I'm just starting coding and I just want it to input a date, then output a day of the week.
Code: #include <iostream> #include <cmath> using namespace std; int main() { int startday = 0, sm = 1, sd = 1, sy = 2000, cm = 0, cd = 0, cy = 0; cout << "Please enter the current month, day, and year: ";
I am writing a C++ program which takes date & time input from the user. This is then parsed into a struct such as:
struct time { short year; short month; short day; short hour; short min; };
My question is: how can I convert such a struct into a time_t object, which is an unsigned long giving the time as the number of seconds elapsed since the epoch Jan 1st 1970, 00:00, as set out in time.h.
I am wondering if this can be achieved using the standard library, or whether I just need to write a function to perform the appropriate arithmetic.
I'm trying to write a program that uses the Boost library to input a string date in the format mm/dd/year and outputs to the string its corresponding day of the week. I wrote the program that I thought would accomplish this, but it doesn't seem to work. Below is the code I wrote:
When I compile this using codeblocks it gives me the error "In function `ZN5boost9date_time19month_str_to_ushortINS_9gregorian10greg_monthEEEtRKSs':| C:Users osaDesktop est3........Liboost_1_55_0oostdate_timedate_parsing.hpp|67|undefined reference to `boost::gregorian::greg_month::get_month_map_ptr()'". And it takes me to the file date_parsing.hpp and highlights line 67. I don't understand why this isn't working.
I have an assignment in which i must create a program which prompts for user input of current and birth date, which will compare said dates and output if its your birthday or not. I've completed a large portion of it, but cannot figure out how to get the user input of month as an integer such a 2 into February.
#include <iostream> using namespace std; class DayOfYear { public: void input();
Now I would like to extract the data inside these comment tags and insert into excel sheet. Need to extract the comments in the xml tags shown in the able format? For example I want the value inside the <Autor> tag.
I am a math teacher who is taking a programming class. My district wants to incorporate some programming tasks into the high school math curricula. I am working on a project to calculate a final grade and output this along with a comment to a text file. The following data is the input that I created:
My program had a requirement to ignore an input beginning with a # sign. The input is entered by user from keyboard. I wanted to know how to use cin.ignore to achieve this.
i'm making a program that, given a person's birthdate or any other date, will display the day of the week of the person was born.
There is this part where it says "use a switch statement to make this calculation, If desired month is 12, add the number of days for November, if desired month is 11 add the number of days for october....
So it's suppose to start with "case 12 :...
I can't figure out what to write for the statement....
I have two date/time structures which I'm populating, but when I populate the second one it sets the same values in the first. This is what I've got so far
I'm trying to write a simple program that extract the FAT information from a FAT32 virtual Hard Disk.I have the following structures regarding the FAT format:
Code:
//BOOT RECORD typedef struct NF_BOOT_RECORD { unsigned char BS_jumpBoot[3]; //EB 58 90 = JUMP 58 NOP (Jumps to boot code). Also E9 is acceptable. unsigned char BS_OEMName[8]; //Either MSWIN4.1 or mkdosfs unsigned short BS_BytesPerSec; //Little endian. The size of a sector. 128,256,512,1024... unsigned char BS_SecPerClus; //The number of sectors per cluster (1 CLUSTER = BPS*SPC BYTES) unsigned short BS_RsvdSecCnt; //The boot sectors (this) are included. That makes at least 1. }
[code]...
Everything seems to work fine. Mostly. The only problem, is that the program gives me the following output:BS_NumFATs shouldn't be 0. In fact, I've checked inside the structure memory, and the information seems correct. BS_NumFATs is 0x02, not 0x00 (It's the byte at offset 0x10, starting at 0x00).
I've checked the order of the structure fields, and their types, comparing them to the FAT specification given by Microsoft (File fatgen103.pdf), and it seems fine, unless I'm missing something. So I don't know why it gives 0 instead of 2, if I'm missing something.It's a Win32 program compiled with GCC version 4.4.0
I wrote a script that generates n random pixel positions and draws them to the screen. Works well. Now i tried to rotate them. Rotating does work too. But it does not work as i planned it.
paramters 'angle' and 'timestep' work somehow, but not as they should do. the function 'move' is supposed to rotate the pixelfield 'angle' degrees in a given direction, addicted to the 'timestep' parameter. 'timestep' is needed time for drawing in one single game loop.
rotation point is the middle of the screen. when i set angle to 10 it should rotate 10 degrees / second. Instead it's rotating very very fast and all stars are moving nearer to the center of the screen, so after x rounds there is just 1 pixel left in the middle of the screen. there is a kind of gravition.I'm working with SDL2. What I did find out:
FPS is <= 60, 'cause of the 'SDL_RENDERER_PRESENTVSYNC' flag. When i skip that flag, for any reason the 'gravition' would take more time. FPS is <= 1400 then, 'though i got a natural game loop (i hope):
I need writing a program in c++ that will get the input of 50 different users for the following the fields (surname, other names, sex, status, date of birth) and after entering the data for these 50 users, it will then output only the list of all FEMALE users who were registered...
#include <iostream> #include <string> using namespace std; int main () { string surname, other_names1, other_names2, status, sex, dob;
[Code] ....
I don't really know what to do next - all my attempts have not really given me the result I want.
is there way that I go like: cout << c1; not overloading << operator; and it shows me a value of c1.x? just wanna replace c1 with that value; I need sth similar to indexer from c#.
I have a dynamic storage class based on a vector. The elements of this class shall be addressable via a string.
I have something like the following:
StorageClass* test = new StorageClass(); while(notEnd) { test->setValue("name3", 3); test->setValue("name2", 4);
[Code] ....
The Storage class is implement with a vector having to attributes per entry, the first one is name the second one is value. If the setValue function is called, Igo through the whole vector to find the correct item via the name and than i set the new value.
At the end of the loop i want to write out the data into a comma separated value file (*.csv). This shall be done generic by the writeLineToFile() function of the StorageClass.
As a want the columns in csv file to be sorted in a specific way a thought about a preInitalisation routine at the beginning of the program which builds a the vector with all possible entries as something like this in order to define a specific output order.
I now have 2 places in the code where i write down the "fieldnames".
I was wondering if there is a possibility to check if the fields called by the setValue function were first aranged in the vector by the assigned() function before or bettwer while compiling the programm.
I thought about MAKROS with #define XYZ and #ifndef XYZ #error to do though, but currently i reached a dead end and find no solution for my problem.
I need to use an instance of an object in a header file. The object requires a lot of pre-computation to be created.
I want to assign it to a "static const *NAMEobject*" field in the .h file, once it has been created. I assume that it is better to create it in another file and somehow pass it into the .h file.