I want to create a new data type called an inf_t. It's basically infinity (which for C++ is 1.7e+308). The only reason I want this is because I want to overload the cout << operation to print out INF/inf. Should I do this in a struct?
I am trying to create a flexible interface for my CL application. And what i have is this :
Code: using namespace std; // iplcp -i queryFile -d databaseFile template <typename INT, typename CHARA> class API {
vector<string> files; vector<INT> flags;
[Code] ....
and in main :
int main(int argc, char **argv){ //set variables API<int, char**>args(argc,argv); cout << "In file: "<< args.GetOpt("i") << " Db file: " << args.GetOpt("h") << endl; }
// first thing to be printed should be string and the second int
I know this is not probably the best way to but i am laying around and was curious if something like this could work . Are there any good C++ templates for CLI applications from which i could learn?
My app crashes when I attempt to create a CWnd as shown below. I am attempting to create the CWnd with a a parent of type CFormView. Why this might be crashing?
Code: mfc100ud.dll!AfxGetInstanceHandle() Line 21 + 0x20 bytesC++ mfc100ud.dll!AfxRegisterWndClass(unsigned int nClassStyle, HICON__ * hCursor, HBRUSH__ * hbrBackground, HICON__ * hIcon) Line 1462 + 0x5 bytesC++
And the line that crashes here us the AfxGetInstanceHandle() call:
Code: LPCTSTR AFXAPI AfxRegisterWndClass(UINT nClassStyle, HCURSOR hCursor, HBRUSH hbrBackground, HICON hIcon) { // Returns a temporary string name for the class // Save in a CString if you want to use it for a long time LPTSTR lpszName = AfxGetThreadState()->m_szTempClassName;
// generate a synthetic name for this class HINSTANCE hInst = AfxGetInstanceHandle();
I've written this class and struct to create a singly linked list. The data is stored in the binary file which I've opened and read. I'm trying to load said data into a class type array. The errors I'm getting are "incompatible types in assignment of 'StatehoodInfo' to char[3]" Lines 130-134 is what I was working on.
So in a nutshell I have to write a program that grabs a random line from a file and exchange the numbers for words from other files to create a poem. The problem I have is that when I go to output the parts of the ntca it gets all jumbled and writes over each other. (See output below)
I saw something about a memory leak, but I couldn't see how that could be happening in this program. It's a basic intro level program for a class and I'm just a little stuck.
Code:
void create_poem(const int poem_lines) // called from main function { //Peform each for each line for(int x = 1; x <= poem_lines; x++) { char begin_line[1000];
[Code] ....
Everything works perfectly except for the output which looks like this :
Code: A 2 2 1 and 1 3 1 // <-- this is the line before translation junkcarrnet
As stated, I know everything else works through debugging purposes. Just the overwriting is my only problem.
If I am asked to declare a data type for Date which should be in the format DD/MM/YY, which data type should i use for it? Is there any data type known as Date in C?
In the program I'm writing, I'm creating a linked list of students with individual data read from a file. At the moment, I have written two functions to accomplish this; one that creates a student node and fills it from a line file, and a second that calls on the first to create a linked list. It seems to work fine except for one thing; It seems that EOF is being reached first, but the function continues on anyways? Here is my code so far...
In class we were asked to create a C++ BTree program that would allow a user to input the following data types and then store said data in a .txt file:
0. ID 8 bytes
1. First name 30 char
2. Last Name 30 char
3. Street Address one 30 char
4. Street Adress two 30 char
5. City 30 char
6. State 20 char
7. Zip 10 char
8. Country 30 char
(I'm not particularly asking for full code, pseudo code would also be great). I had a great deal of my work done, unfortunately, the computer I was working on crashed, corrupting my files.
I have two char variables, m_GPSOffset[13] and m_FileName[100]. When m_GPSOffset has a value assigned to it, say for instance +11:25:30. The first entry of the value, in this case +, is always stored in m_FileName. I am clueless on why this is occurring.
I know that an int is usually 4 bytes, ranging from -2^31 to 2^31-1 for a signed int and 0 to 2^32-1 for an unsigned int. My question is simply, bit-wise (I know they are labelled in the code), how does it determine whether to show -2^31 or 2^32-1 if it was 11111111 11111111 11111111 11111111 in bits? Is there a 5th byte to tell the compiler what data type to treat the input as?
Working on a Project Euler problem and the question asks for the largest prime number that is a factor of 600851475143. As you can see, this is significantly larger than the maximum of a long data type, which maxes out at 2147483647.
I'm running on Windows 32, so int64 is not a valid option for me. It seems like I'll likely have to use a different language to solve this problem.
I'm currently trying to solve a programming assignment and i got the logic of it, however i find it hard to implement.
What i need to do basically is fill an array with objects. Each object is a class that contains only one type of data. This means i can place int, double and string for example in one simple array.
However i can't figure out how to read data and then decide what it is. Even if i use templates once i call the function i have to give it a type, so getType<int> for example will not work with double or string.
I know about typeID and how to use it, i just can't figure out where to use it.
I know how to store numeric data using keywords int, long, float, and so on. I'm making my own program called "Who is your soul-mate".The only question I want to ask is what's the keyword for storing alphabet data? As you can see below on my source file. I want to replace "int" keyword with another keyword that can store alphabet data. It's all in standard C.
#include <stdio.h> int soulm01, soulm02, soulm03; int year_of_birth; int main(void)
Ok so I have this simple program that gets input from a user. I just want to put in a line of code to make sure that hte user can't type in something like "pizza" , I want to make it say that if the user puts in something that is NOT a number they will get a error back saying "Wrong! try again!" Here is my code :
#include <iostream> using namespace std; //Summation Program //Function Prototypes int get_num(); void compute_sum(int num, int &sum);
Assume the user has already put in the number of students (hence my variables numStuds, which will most likely be irrelevant to my problem).
So suppose I have this:
void inputStudentInfo(string *names, int *movies, const int numStuds) { for(int i =0; i < numStuds; i++) { cout << "Enter student name: "; getline(cin, names[i]); read_string(names[i]);
[Code] ....
Then I have my data type checking function:
//Data-Type Checking for strings string read_string(string Sname) { while(!cin.good())
[Code] ....
I am getting errors. I know the problem I think is that I am trying to data type check for a string made up of pointers* with just a string but I don't know how I am supposed to check this?
I program unix sokcet programming , and part of my code is ti open file from server and open it , but i surprised with this wierd error i dont have any reason for it ?
I've seen some threads that include the information about what data types one has to use usually to put a number of 12digit. But honestly speaking none of them works for me & it takes me a lot suffering about the data type. Even I've googled but I didn't get any specific result.
So, which data type I'd have to use to enter 12digit number.
I'm writing a code to find the largest prime factor of the number 600851475143
Can you use data type double or float for an array? ie
double n[]; or float a; float m[a];
My code wont accept me changing the data type..will on accept int data type. I get the following error when I try to change the array to double or float..
3310E:C++vector.cpp[Error] invalid types 'double [1000][double]' for array subscript