15,300 Posted Topics
Re: If its a stack problem as ^^^ suggested you could also just allocate the array [icode]double* dblData = malloc(ARRAYSIZE * sizeof(double));[/icode] | |
Re: Assuming this is an MS-Windows program you could put the settings in the registry, such as HKEY_CURRENT_USER/Software/<Your Program Name Here>. That way your program can get the settings regardless of where the program is on a computer. | |
Re: Which specific fuction are you talking about? win32 api functions normally return 0 if the function failed. >>is there any other way i can do this in a easier/better manner Write your own wrapper for the win32 api function that throws an exception, similar to the one that c++ new … | |
Re: You can't just skip over fields. Read the entire line then extract what you want from it and discard the rest. | |
Re: Nope, not me. What compiler and operating system. Its possible the lib you are attempting to use is 1) compiled by a different compiler, or 2) written for a different operating system, or 3) corrupt. | |
Re: your class declarations are terrible! One-letter variable names is highly discouraged because they mean nothing to anyone except the original author, then he will forget what they mean after a couple days. I'd suggest starting by rewriting the classes to use more descriptive variable names. As for variable z? I … | |
Re: Have you tried [URL="http://lmgtfy.com/?q=graphics+for+assembly+language"]ths?[/URL] Your 16-bit assembly program can not call any of the win32 api graphics functions so you will have to bite the bullet and write it all yourself. I would suggest you get Turbo C graphics library and learn how to call those functions from your assembly … | |
Re: Whether you use Show() or ShowDialog() depends on whether you want a modeless or model dialog window. Below code works for model dialogs. First close Form1 then show Form2. After Form2 is closed you have to show Form1 to make it visible again. [code] private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) … | |
Re: 1. Don't try to do them all at the same time, but do them one at a time. Don't start on the second problem until you have finished the first. 2. Post the code that you have already written (and use code tags as [URL="http://www.daniweb.com/techtalkforums/announcement8-3.html"]explained here[/URL]) , tell us what … | |
Re: lines 8 and 9. Why are those loops counting from 0 to 10? Array em only contains 3 trings and array e contains 2 strings. line 17: array em does not contain a NULL pointer, so line 17 will do nothing. There are a couple ways to do what you … | |
Re: what compiler are you using? If you are using a 32-bit compiler then you can use win32 api functions FindFirstFile() and FindNextFile(). google for those functions and you will find example programs how to use them. But if you are using something like Turbo C then there may be no … | |
Re: >>How i can make a .o file? Use g++ compiler. The other alternative is to write your own compiler. | |
Re: >>sizeof(uint16_t) * 16 Wrong. All that gives you is the number of [b]bits[/b] (not bytes) in one integer. what you want is the size of one of the arrays, such as [icode]ARRAYSIZE*sizeof(uint16_t)[/icode] >> do i need to use strcpy No. strcpy() works on strings of text data, not numeric data. | |
Re: in square.h -- lines 13-17. You can't put executable code in header files like that. If the intent is to make them inline, then do it like you did on line 9, what is [icode]void set_values(int a) {x = a;};[/icode] square.cpp: delete conio.h and replace getch() with cin.get(). No point … | |
Re: You can only read bytes, never bits :) Open the file in binary mode then use file.read() to read into a buffer of 1000 bytes [code] unsigned char buf[1000]; ifstream in("filename",ios::binary); in.read(buf,sizeof(buf)); [/code] | |
Re: You can do this without reg expressions. Note: The code below was not compiled or tested. [code] #include <stdio.h> #include <string.h> int main() { char line[255]; char* ptr; FILE* fp = fopen("filename.txt","r"); while( fgets(fp,line,sizeof(line) != NULL) { ptr = strstr(line,"<From: "); if( ptr != NULL) { // got it, so … | |
Re: [URL="http://www.codeproject.com/KB/miscctrl/pgllib.aspx"]Here[/URL] is one way to do it. You might want to install VC++ 2010 Express or Code::Blocks instead of using Dev-C++. | |
Re: filin was never opened. I always find it easier to use ifstream instead of fstream for input only strweams. | |
Re: >>char* anArray[] That parameter is a 2 dimensional array, what you are trying to pass is a single character. Now, down in main(), you declared [b]sortArray[/b] as a single-dimensional array. That means you can not put more than one string into it. Line 50 will only let you enter a … | |
Re: What operating system are you using? TSRs are almost useless with MS-Windows | |
Re: Works ok for me. Maybe there is something else wrong with the way your program is reading the file. Try this little program to see if it works with your text file. [code] #include<iostream> #include <fstream> #include<string> #pragma warning(disable: 4996) int main() { std::string line; std::ifstream in("TextFile1.txt"); while( getline(in,line) ) … | |
Re: You can use resize() when you originally create the vector so that it will contain room for using [] to insert items [code] vector<int> ay; ay.resize(10); for(int i = 0; i < 10; i++) ay[i] = i; [/code] or you can use an iterator [code] int main() { int count … | |
Re: [URL="http://www.imdb.com/title/tt0031381/"]Gone With The Wind[/URL]. Great 1939 epic about the Old South (USA) Civil War and the mixed-up love between four people. The most commonly quoted line in US today is: Rhett Butler said "Frankly, my dear, I don't give a damn." Also anything directed by [URL="http://en.wikipedia.org/wiki/Cecil_B._DeMille"]Cecil B. DeMille[/URL] | |
Re: Don't use [b]std[/b] in c++ programs as std is the name of a namespace. You have to repeat the typedef statement in MyProjDlg.cpp [icode] typedef vector<LPTSTR> StudentData; extern StudentData stdData; [/icode] | |
Re: We won't write it for you, but help you with what you don't understand. What exactly don't you understand about the assignment? Have you even made an attempt to write the program? What compiler and operating system are you using? | |
Re: How do you think 4/2 is represented in memory? If you use doubles it will be 2.0000... Similarily 4/3 is 1.3333... in memory. Its NOT just a string -- that is the binary representation. If you want to know how doubles are formatted in memory then you need to study … | |
Re: create a union [code] // declare types enum data_types { undefined_type = 0, bool_type, char_type, short_type, ushort_type, int_type, uint_type, // etc for each type you want to support }; struct data { data_types valid_type; union types { bool b; char c; short s; unsigned short us; int i; unsigned int … | |
Re: Before attempting to decrypt that you need to know the shift value, and whether it was shifted right or left. I suppose you could solve it by iterating through all 26 possible shift values ('A' - 'Z' = 1-26) assuming case is ignored.If not then there would be at least … | |
Re: Welcome to DaniWeb -- glad to have you here. Almost never to old to get back to school and learn new skills or trades. | |
Re: Sure -- if you know assembly language you can access the math coprocessor, but there's not much point in doing that because that'sa what C/C++ does anyway. | |
Re: cacls is depreciated. Use icacls and see if that works for you. | |
Re: [code] struct matrix* InitMatrix(int x, int y, int z) { struct matrix* m = malloc(sizeof(struct matrix)); // initialize the structures elements <snip> return m; } [/code] Free it in reverse orderof allocating it. | |
Re: using '@' as a deliminator in getline() is not what you want to do anyway. To make a word counter use >> operator, not getline() [code] string input; int word_count = 0; while( cin >> input) { if( input == "@@@" }\ break; word_count++; } [/code] | |
Re: Please copy and paste the actual contents of the first few entries in the transction file so we can see what it really looks like. If there is a space between d or w and the value then reading the file should be easy and straight forward [code] char action; … | |
Re: what I would do is this [code] class MyBasic { public: friend ostream& operator<<(ostream& out, const MyBasic& mb); friend istream& operator>>(istream& out, const MyBasic& mb); // other class stuff here } [/code] Then in the *.cpp file just create two overloaded functions that do not contain the [b]friend[/b] keyword. | |
Re: Not sure what you are asking. Maybe you should post an example of what you want. | |
Re: You will have to add a resource file to the project. [URL="http://www.thefreecountry.com/programming/resourceeditors.shtml"]Here[/URL] are some free resourc file compilers. | |
![]() | Re: There is no such thing as Visual C++ 2o1o -- you probably mean Visual C++ 2010. If you want to program then you must know the difference between 'o' and '0' :) Use VC++ 2010 -- its newer and supports current c++ standards better. The last time I used Borland … ![]() |
Re: What does the subject of pointers have to do with the subject of data structures? Other than a structure can contain pointers. [URL="http://daweidesigns.netfirms.com/cgi-bin/pointers.php"]Here [/URL]is an interesting article about pointers written by DaWei | |
Re: Whether a byte is signed or unsigned, depends on how you want to treat it. Maybe you want to study [URL="http://stackoverflow.com/questions/247873/signed-versus-unsigned-integers"]this thread[/URL]. Whether the value of a byte in memory is teated as signed or unsigned all depends on the instruction you want to use. The value of the byte … | |
Re: delete line 7 and move the return between lines 9 and 10. That else statement on line 7 is causing the function to return after the virst attempt to chedk the value of *s. | |
Re: lines 21 and 22. open() method takes const char*, not std::string. You have to use string's c_str() to make the conversion. [icode]input.open(inf.c_str());[/icode] | |
Re: delete the loop on lines 4-7 because the dest buffer may contain some text that the program needs to keep. That loop destroys all that text. The first thing the function needs to do is find the end of the text, if any, that is in the dest buffer. [code] … | |
Re: >>why if I change AllocString(strlen(s), ©); to AllocString(strlen(s)-7, ©); I can still get a good result? AllocString() doesn't actually copy anything into the newly allocate memory but just returns a pointer to it. If you allocate fewer bytes than you try to copy into that memory the outcome will be … | |
Re: >> wanted to edit and correct the post but can't figure out how. You only have 30 minutes to make changes. After that you are just SOL ("Sadly Outta Luck" (polite form) for anyone who doesn't know that that means). Your code snippet is in error. [icode]char a;[/icode] should be … | |
Re: line 10. The break is unnecessary because of the return statement on the previous line. line 9: wrong. You want [icode]return &s[i];[/icode] line 19: That will most likely display 0 if the function every returns NULL, which may not be what you intend. Otherwise your program looks good :) | |
Re: >>strcpy(array1[n],array[i]); Just use simple assignment [icode]array1[n] = array[i];[/icode] | |
Re: You need to post most recent code. If you want to just check for a single character than [icode]if( argv[1][0] == 'n')[/icode] | |
Re: There is a reverse() method in std <algorithm> header file [code] #include <string> #include <algorithm> #include <iostream> using namespace std; int main() { string name; cout << "Enter your name\n"; getline(cin,name); reverse(name.begin(),name.end()); cout << name << '\n'; } [/code] |
The End.