15,300 Posted Topics

Member Avatar for andy257

[QUOTE=andy257]Can c++ make programs that you can install onto a computer like you would software you buy from a shop. Basically does it allow you to make the installer setup stuff. Even if you program is very very basic. Is there software that does this for you and you just …

Member Avatar for TIMBUCK
0
195
Member Avatar for SpS

my company forbids use of goto, and it is strictly enforced during peer review. Yes, programmers are NOT free to just code any way they wish -- there are coding standards and the code is periodically reviewed to insure those standards are followed. There is absolutely never justification for its …

Member Avatar for Narue
0
152
Member Avatar for mina1984
Member Avatar for Ancient Dragon
0
122
Member Avatar for SpS

It is indeed a parameter passing technique -- there are only two ways to pass something, by value and by reference. Pass by reference can be done in one of two ways -- a pointer (C) or reference operator (C++). The three differences I can think of 1. use of …

Member Avatar for Ancient Dragon
0
197
Member Avatar for debe2000

how to do that depends on the operating system. You can either use operating system-specific GUI drawing functions, or some SDK such as QT that is mostly os-independent. Either way, it will take several months to learn. There are some commercial graph packages you can buy -- some may even …

Member Avatar for Ancient Dragon
0
71
Member Avatar for imest

get rid of that silly semicolon ';' at the end of the if statement. The next line, print(...) need a semicolon at the end.

Member Avatar for imest
0
153
Member Avatar for 123abc

[QUOTE=123abc]That is definitely NOT me. It may be someone from my same class.[/QUOTE] read that other thread and use the same suggestions. Or do you want somebody to do your work for you?

Member Avatar for 123abc
0
242
Member Avatar for Joaquine

you are attempting to declare a function CalcDepr() within another function main(). You can't to that. Move all the code for CalcDepr() outside function main() and it will probably compile ok, unless of course there are other errors. [edit]Nevermind -- Narue answered your question. Too bad we can't delete our …

Member Avatar for Joaquine
0
138
Member Avatar for SpS

the parameter to free() must be the same pointer that was returned by malloc(), calloc() or realloc(). Your program destroyed that pointer in the printf() statement. Why don't you use array a just like any other array instead of using pointer arithemic [code] for (i=0; i<SIZE; i++) a[i] = i …

Member Avatar for Drowzee
0
172
Member Avatar for k_en

Well, it has nothing at all to do with MFC. You probably created a console application and tried to code a MS-Windows win32 api application. You will probably have to start all over and create the correct type of application (win32 application).

Member Avatar for Ancient Dragon
0
109
Member Avatar for superservo15

double quotes mean a null-terminated string, single quotes is a single character. Replace the double quotes in the if statement to single quotes. [code] if ( term1[1] == '(' ) [/code]

Member Avatar for ITgeneration
0
153
Member Avatar for stupidenator

if you know the format, then its pretty easy [code] string date = "01/02/2005"; // 1 Feb 2005 int month = atoi(date.substr(3,2).c_str()); // do day and year similar to above [/code]

Member Avatar for stupidenator
0
222
Member Avatar for SpS

[QUOTE=Narue] that still doesn't guarantee that your system is 32-bit. ;)[/QUOTE] Actually, it says nothing at all about the system. I have a new 64-bit system and sizeof(int) is still 32 because that is what the compiler said it is, not the system. It would be impossible to run 32-bit …

Member Avatar for SpS
0
357
Member Avatar for pre_wreck

you are trying to do it the hard way. fgets() and strtok() functions that make it very simple. fgets() reads a whole line, and strtok() splits it into its individual parts based on a token, such as a space, that you give it. [code] #include <stdio.h> #include <string.h> #include <stdlib.h> …

Member Avatar for pre_wreck
0
176
Member Avatar for SpS

[QUOTE=Narue]> there's a run-time assertion if the allocation size exceeds a certain limit, and 4294967295 is beyond that limit. [/QUOTE] The parameter to malloc is a size_t (on my compiler it is defined as unsigned long). So how in the world can you ever pass that function a value greater …

Member Avatar for Narue
0
560
Member Avatar for bumsfeld

A NULL pointer is a pointer that points to address 0 [code] const void *p = 0; [/code]

Member Avatar for Ancient Dragon
0
236
Member Avatar for bumsfeld

I think the longest string that can be made in C or C++ is the maximum value of an integer (as defined by size_t). Compilers will concantinate string liters just by NOT using ';' between lines. Note the use of quotes below The semicolon ; only appears at the end …

Member Avatar for Narue
0
320
Member Avatar for SpS

passing an object by value calls the copy constructor because a new copy is created -- and that would mean an infinite recursion. Also, it always faster to pass c++ class objects by reference than by value.

Member Avatar for Ancient Dragon
0
95
Member Avatar for ashwinperti

stdio.h contains function prototypes (declarations) and structure definitions from the standard C stream library. You cann't write either a C or C++ that uses any of those functions without including stdio.h. If the program doesn't use anything from it, then there is no need to include it.

Member Avatar for Narue
0
116
Member Avatar for aminura

c and c++ compilers do not do range checking on enumerations or pointers. It lets you hang yourself with a very very long rope if you want to. Its up to the programmer to validate data ranges and buffer sizes before using or doing something with them. Those are two …

Member Avatar for aminura
0
373
Member Avatar for mina1984

get it from the keyboard as a string instead of an integer, then create a loop to check each digit in the string. You don't need modules, division, shifts, or any other math operations, unless, of course, that is a requirement of the problem.

Member Avatar for mina1984
0
228
Member Avatar for aminura

you shouldn't call the constructor directly like in function show(). Do that in a set function. This works ok in VC++ 6.0 compiler. Nearly all c++ programs use set functions similar to below -- none use private constructors to do it. [code] #include<iostream> using namespace std; class A { private: …

Member Avatar for Narue
0
400
Member Avatar for ashwinperti

Your first example is ALMOST how to multiply two arrays. A[100] does not exist in an array with 100 elements. you have to create a loop and multiply each array element in array A by the corresponding element in array B. Then the result has to be stored someplace, either …

Member Avatar for Rashakil Fol
0
246
Member Avatar for bops

do you want the drive letter of the drive on which the os is installed? such as "c:"? or the path that the program is starting from? argv[0] or win3w2 api function GetModuleFileName() will give you the latter.

Member Avatar for bops
0
149
Member Avatar for stinus

you didn't do anything "wrong". There are a lot of porting issues you must deal with when porting C programs to C++. Most (if not all) the errors you are getting are probably because the functions have not been prototyped before used in main(). You need the *.h file that …

Member Avatar for stinus
0
500
Member Avatar for SpS

[QUOTE=sunnypalsingh]Both The Codes Works Fine.....Now What??Why Memory Allocation[/QUOTE] There are many many cases where you do not know the text that the character array contains. For example, suppose I ask you for your name. The program has to put the answer some place, if the pointer doesn't point to some …

Member Avatar for SpS
0
163
Member Avatar for djbsabkcb

[code] o << num1.read_list(i);[/code] function read_list() returns void, so the above line will not compile.

Member Avatar for djbsabkcb
0
149
Member Avatar for vitabrits

Are P, Q, A and B individual data elements? If they are then the first a. (P*Q) + (Q*P) + (R*S*T) + (R*S*T) + (T*R*S) I don't know the significance of the ' character, so the above may not be completly correct.

Member Avatar for Drowzee
0
147
Member Avatar for WVTrammell

How difficult the program is to port all depends on the program. If the program uses strickly ANSI C or C++ functions there should be few if any porting problems. But most programs use some hardware-specific functions. You will just have to take them one at a time. First attempt …

Member Avatar for Ancient Dragon
0
89
Member Avatar for Coach_Nate

yes. [code] char * foo() { static char array[] = "Hello World"; return array; } int* foo1() { static int array[20]; return array; } [/code]

Member Avatar for SpS
0
115
Member Avatar for stupidenator

get a free compiler from [url]www.bloodshed.net[/url]. See sticky for books

Member Avatar for stupidenator
0
193
Member Avatar for openhiem

in VC++ 6.0 IDE create a "win32 Dynamic-Link Library" project. Step 1 of the wizard has 3 radiao buttons select "a DLL project that exports some symbols" then press Finish button. The wizard will generate the DLL project. Look at the *.cpp and *.h files. They will show you how …

Member Avatar for jbennet
0
230
Member Avatar for Acidburn

something like this will hold an unlimited number of strings that are of unlimited length. [code] const char *array[] = { "jane", "John Deer Company", "The quick brown fox jumped over the lazy dog", "Adam", "Smith" }; [/code]

Member Avatar for Lerner
0
223
Member Avatar for nir_kar

see the <limits.h>, which defines the max value of all integer types. Allocations cannot exceed those values.

Member Avatar for Ancient Dragon
0
54
Member Avatar for Coach_Nate

you probably created the wrong kind of project. You should have created a Console Application, not a Windows Application. With a Console Application your program compiled with no errors or warnings. Of course I had to add a main() function to the code you posted.

Member Avatar for Ancient Dragon
0
108
Member Avatar for julie derifield

put the dll in a place where the os can find it, one of the directories in the PATH or in the same directory as the program you are trying to run.

Member Avatar for Ancient Dragon
0
50
Member Avatar for Drowzee

not quite certain what you want. Do you want to convert the unsigned short to CString? CString's Format function is identical to sprintf() and printf(). [code] CString str; unsigned short test = 0x1234; str.Format("%X", test); [/code] Of course if you display the result, the string will be "1234".

Member Avatar for Drowzee
0
162
Member Avatar for Ancient Dragon

Is there a c++ std:: function that will trim trailing spaces from std::string? I know how to do it myself, but I was wondering if anyone knows of something in <altorithms> or elsewhere? Thanks

Member Avatar for Ancient Dragon
0
117
Member Avatar for BenPage

[URL=http://www.codeproject.com/cpp/ymatrix.asp]CodeProject[/URL] has at least one that you might find useful.

Member Avatar for Ancient Dragon
0
93
Member Avatar for SpS

seems to work with c++ STL classes too ;) [code] #pragma warning(disable: 4786) #include <iostream> #include <vector> #include <string> using namespace std; int main() { vector<string> array; array.resize(2); char* p1 = (char *)&array[0]; char* p2 = (char *)&array[1]; cout << p2-p1 << endl; cout << sizeof(array[0]) << endl; return 0; …

Member Avatar for Stoned_coder
0
444
Member Avatar for j1979c

This works with Dev-C++ but not with VC++ 6.0 (I think it is a compiler bug) [code] HWND hWnd = GetConsoleWindow(); ShowWindow(hWnd,SW_SHOWMAXIMIZED); [/code]

Member Avatar for Electrohead
0
307
Member Avatar for jahowell01

most of the problems are typing errors -- such as using colon when semicolon is expected, and misspelled words. Using Dev-C++ I had to change the top like this: Note <iostream> without .h extension. [code] #include <iostream> // allows program to perform input and output using namespace std; // program …

Member Avatar for SpS
0
506
Member Avatar for Ancient Dragon

_tempnam() always returns a filename in the "c:\\temp" directory, regardless of the parameters. This example was extracted from MSDN. I need to generate a unique filename in a directory other than c:\temp -- any ideas how to do that other than writing my own function? maybe a c++ solution? Note …

Member Avatar for Ancient Dragon
0
272
Member Avatar for Domo

elements of an array are not called "records". A record is something you play on a phonograph machine, history of your activities in prison, or a complete collection of data in a file.

Member Avatar for l3.azarmehr
0
135
Member Avatar for Drowzee

I would have written the first one like this [code] printf("|Val=%s",outString); [/code] but if your goal is to concantinate two strings into a single buffer [code] char buf[255]; strcpy(buf,"|Val="; strcat(buf,outString); //or (same as above) sprintf(buf,"|Val=%s",outString); [/code] Neither of the above two are safe because neither strcat() nor sprintf() check for …

Member Avatar for Ancient Dragon
0
82
Member Avatar for Enzo

ever hear of [URL=http://www.google.com/search?hl=en&q=how+to+send+email+with+c%2B%2B&btnG=Google+Search]google[/URL]

Member Avatar for Enzo
0
80
Member Avatar for yaniv

Your program is not what the question asked. It wants you to enter a 3-digit number all at one time, not one digit at a time. So your program should get the number as a string, then test each character of the string. Use fgets() to get they keyboard input. …

Member Avatar for yaniv
0
2K
Member Avatar for Acidburn

what do you mean "it failes"? it won't compile? it won't run? what error(s) do you get? Note: unless its just a posting error, it needs a semicolor at the end of the cout line. Also, how is buffer declared?

Member Avatar for Acidburn
0
87
Member Avatar for DotNetUser

you cannot access class objects/methods from class static methods. There are at least two ways to overcome this: 1. pass a pointer or reference of an instance of the object to the static method, then access the objects through this pointer/reference. 2. make the object(s) static.

Member Avatar for DotNetUser
0
89
Member Avatar for Micko

only write out the number of bytes read. At some point (at end-of-file) the number of bytes read will be less than the buffer size. This would go much faster if you read/write with larger buffer size -- say 255 characters. [code] int main() { [color=red] char buf[255];[/color] ifstream fp_in("my.txt", …

Member Avatar for Narue
0
579

The End.