2,384 Posted Topics

Member Avatar for masa

For native types I don't think it makes a difference. For user-defined types I think it may mean the difference (if any) between calling (the default constructor and [probably not in this case?]) the assignment operator and a copy constructor. Real C++ people...?

Member Avatar for Dave Sinkula
0
213
Member Avatar for aminura

[QUOTE=aminura]Can somebody please tell what does this function prototype indicate--[CODE]const char* fun( char const *,const char*);[/CODE]Is it some thing like that the return type would always be constant char ?[/QUOTE]It may be more helpful to read [inlinecode]const[/inlinecode] as "read-only". You the programmer are not supposed to be writing to it. …

Member Avatar for aminura
0
119
Member Avatar for JoBe

Some light reading: [url]http://ldeniau.home.cern.ch/ldeniau/html/oopc/oopc.html[/url] :p

Member Avatar for Ancient Dragon
0
139
Member Avatar for gmv

Let sleeping threads lie. If you must open a new thread, [thread=35517]refer back to the original[/thread]. But then you might realize that a new thread would be relatively pointless, much like replying to a dead thread.

Member Avatar for Dave Sinkula
0
239
Member Avatar for Aldin

[QUOTE=Ancient Dragon]use functions in time.h -- [COLOR=Magenta]today()[/COLOR] returns the current date as an integer, number of seconds since 1 Jan 1970 (I think).[/QUOTE]Do you mean [inlinecode]time[/inlinecode] (which returns a [inlinecode]time_t[/inlinecode], by the way)?

Member Avatar for masa
0
463
Member Avatar for mariposa104

It looks like you still have to implement these requirements:[QUOTE=mariposa104]The clas has attributes length and width, [COLOR=Blue]each of which defaults to 1. It has members function that calculate the perimeter and the area of the Rectangle.[/COLOR] It has set and get functions for both length and width. [COLOR=Blue]The set functions …

Member Avatar for iamlearning
0
254
Member Avatar for bops

Look up [url=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/getfilesize.asp][inlinecode]GetFileSize[/inlinecode][/url]. [code]#include <stdio.h> #include <windows.h> int main(void) { const char FilePath[] = "main.exe"; HANDLE MF = CreateFile(FilePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL); if ( MF != INVALID_HANDLE_VALUE ) { DWORD High, Low = GetFileSize(MF, &High); if ( Low != 0xFFFFFFFF ) { printf("Size : High = %lu, …

Member Avatar for Ancient Dragon
0
544
Member Avatar for Acidburn

I thought we went through this already. [url]http://www.daniweb.com/techtalkforums/post106155-6.html[/url] [url]http://www.daniweb.com/techtalkforums/showthread.php?p=106169#post106169[/url] Is this something new and different?

Member Avatar for Acidburn
0
139
Member Avatar for hanuma4

[url=http://groups.google.com/group/comp.lang.c/msg/88ec0cd40f400cb7]FYI[/url]

Member Avatar for Dave Sinkula
0
142
Member Avatar for Jon182

[code]if(strstr(ch, "hello") == 0)[/code]The return value of [inlinecode]strstr[/inlinecode] is a pointer to the match or a NULL pointer when no match was found. Here you are checking for a NULL pointer, meaning when no match was found, so you would be incrementing your counter at the wrong time. Try this …

Member Avatar for Jon182
0
236
Member Avatar for Operator

It looks like you're trying to use some nonstandard I/O. Compiler/OS?

Member Avatar for Dave Sinkula
0
158
Member Avatar for nabil1983

Another one bitten by scanf. When you enter a number, you generally press [enter], right? That screws things up. [url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1044873249&id=1043284392[/url]

Member Avatar for Dave Sinkula
0
152
Member Avatar for iqbal
Member Avatar for pplqingshi007
Member Avatar for dwks
0
107
Member Avatar for fidelljf
Member Avatar for Lerner
0
140
Member Avatar for DotNetUser
Member Avatar for DotNetUser
Member Avatar for pokerponcho
Member Avatar for Acidburn

I believe [inlinecode]operator>>[/inlinecode] is whitespace delimited, so I'd say something like this. [code]if ( file >> Surname >> Firstname >> Age ) {}[/code][edit]Or maybe with [inlinecode]getline[/inlinecode]: [code] if ( file.getline(Surname, sizeof Surname, ' ') && file.getline(Firstname, sizeof Firstname, ' ') && file >> Age ) {}[/code]

Member Avatar for Dave Sinkula
0
120
Member Avatar for ToySoldier

Do this:[code] while ( [COLOR=Blue]infile>>first>>last>>ss>>st_code[/COLOR] ) { for ( int x=0; x<10; x++ ) { if ( st_code==st_codes[x] ) { st_name=st_names[x]; [COLOR=Blue]break;[/COLOR] } } cout<<left<<setw(10)<<first<<left<<setw(12)<<last<<left<<setw(15) <<ss<<left<<setw(10)<<st_code<<left<<setw(10)<<st_name<<endl; outfile<<left<<setw(10)<<first<<left<<setw(12)<<last<<left<<setw(15) <<ss<<left<<setw(10)<<st_code<<left<<setw(10)<<st_name<<endl; }[/code]

Member Avatar for ToySoldier
0
195
Member Avatar for Loopah

Post your attempt. The basics are something like this: [code] static const char delim[] = " \n"; size_t size = 0; char word[10][20], *ptr = strtok(sentence, delim); while ( ptr != NULL ) { strcpy(word[size], ptr); if ( ++size >= sizeof word / sizeof *word ) { break; } ptr …

Member Avatar for Loopah
0
312
Member Avatar for snl_edupuganti

Possibly. [url]http://www.daniweb.com/techtalkforums/announcement8-2.html[/url]

Member Avatar for Dave Sinkula
0
60
Member Avatar for Keyonts

[QUOTE=Keyonts]I was wondering how deep an average programmers knowledge has to be to be good with c++. Do most just take for granted that these templates work and dont ask questions.[/QUOTE]IMO, a good programmer must be trained to trust the interface. Design to the interface. Work with the interface. Sometimes …

Member Avatar for Dave Sinkula
0
107
Member Avatar for bucsoldier03

[QUOTE=bucsoldier03]i have this program trying to read from a file but i keep getting this error message what am i doing i cant figure it out.[/QUOTE]It might be beneficial to post the error message. It might also be beneficial to post the header file.

Member Avatar for dwks
0
110
Member Avatar for kdw3

You need to make room for the numbers on the bottom, I'd guess. And that would mean you'd need to space out your columns: [code] for (int k = 0; k < 20; k++) { if (scaledfrequency[k] >= row) { cout << [COLOR=Blue]" * "[/COLOR]; } else { cout << …

Member Avatar for Dave Sinkula
0
187
Member Avatar for TimC

One would be the missing semicolon in "Sequence.h": [code]typedef patient SeqItemType[COLOR=Blue];[/COLOR] [/code]Others are things like returning a pointer from a function that is not declared as returning a pointer.

Member Avatar for Dave Sinkula
0
92
Member Avatar for free_eagle

[QUOTE=free_eagle]I don't know what to do and how to do to improve my programming skills. i really need your help , advice and suggestions... [/quote]One of the best ways may be to hang out here and practice answering others' questions. When you've got that nailed down, you've got something. [QUOTE=free_eagle]Even …

Member Avatar for free_eagle
0
181
Member Avatar for Puckdropper

Arrays are zero-based. If you have [inlinecode]T array[10][/inlinecode], it may be indexed from 0-9, not 0-10.

Member Avatar for Dave Sinkula
0
109
Member Avatar for tyczj

Post an attempt. I'd imagine it might look something like this, though. [code]#include <stdio.h> void print(const int value[10][10]) { int r, c; for ( r = 0; r < 10; ++r ) { for ( c = 0; c < 10; ++c ) { printf("%d", value[r][c]); } putchar('\n'); } putchar('\n'); …

Member Avatar for tyczj
0
182
Member Avatar for desertstorm

[QUOTE=desertstorm]Or does that automatically do that when I allocate memory to the nodeList[5].[/QUOTE]No, you need to do that. [edit] Except that this won't go far: [inlinecode]sizeof(void)[/inlinecode] -- you need a type to have a size of that type. [/edit] Why the casts on [inlinecode]malloc[/inlinecode]? If you're using C++, why not …

Member Avatar for Ancient Dragon
0
756
Member Avatar for sahil_logic
Member Avatar for perniciosus
0
408
Member Avatar for bucsoldier03

[QUOTE=bucsoldier03]how do i get to the tutoriols[/QUOTE][url]http://www.daniweb.com/tutorials/forum21.html[/url]

Member Avatar for dwks
0
227
Member Avatar for ToySoldier
Member Avatar for love13chess

[inlinecode]cin[/inlinecode] is whitespace delimited, [inlinecode]getline[/inlinecode] is not. A newline is whitespace too. To get rid of an "unwanted" newline, you may consider reading an extra character using the [inlinecode].get()[/inlinecode] member function. Checking the return values of these input functions is always prudent.

Member Avatar for Dave Sinkula
0
133
Member Avatar for mym

[QUOTE=mym]But the problem is that it only works with certain numbers not all the numbers I input.[/QUOTE]I don't suppose you could tell us what working and nonworking values might be? [QUOTE=mym]I would like to know if I am doing anything wrong.[/QUOTE]Your loop checks quotient before it is initialized for one.

Member Avatar for Rashakil Fol
0
207
Member Avatar for sahil_logic

As for the `strcat`, this is in the Code Snippets: [Strings: Concatenation](http://www.daniweb.com/code/snippet406.html) [edit]And never use [gets](http://www.eskimo.com/~scs/C-faq/q12.23.html).

Member Avatar for Dave Sinkula
0
2K
Member Avatar for mtodd51

I thinking of a number between 223 and 367 -- what is it? [Translation -- do you think you could be a little more specific?]

Member Avatar for WolfPack
-1
653
Member Avatar for imanust

[QUOTE=imanust]but it print out the stars in the following format:[code]********* ******* ***** *** *[/code][/QUOTE]For me, it prints this:[code]*************** ********** ****** *** *[/code]Why do I point out the distinction? Because the first line has 5 more * than the line below it; that line has 4 more than the line below …

Member Avatar for WolfPack
0
99
Member Avatar for johnray31

The first one is because it doesn't see any floating point operations, so the library is not linked. [edit][url]http://cboard.cprogramming.com/showthread.php?p=322171#post322171[/url] The second one is not correct.

Member Avatar for johnray31
0
453
Member Avatar for jack223

[url=http://www.cppworld.com/forum/index.php?showtopic=1041&st=0&#entry6838]Same answer[/url] to the same question.

Member Avatar for geekbutproud
0
2K
Member Avatar for Loopah

[quote]I would like a little help on how to reset the grid to show the next generation though.[/quote]Like this?[code]void resetgrid(int coordArray[][SIZE2], int row, int col) { int i, j; for ( i = 0; i < row; i++ ) { for ( j = 0; j < col; j++ ) …

Member Avatar for Loopah
0
633
Member Avatar for kahaj

[QUOTE=kahaj]Can't get this to compile for some reason. Anyone have an idea what's going on with it?[/QUOTE]Another victim of the "poorly indented code" bug: you have an extra closing [inlinecode]}[/inlinecode] at the end of the file.

Member Avatar for Dave Sinkula
0
240
Member Avatar for johnray31

johnray31: I believe you are looking for the [url=http://en.wikipedia.org/wiki/Xor_swap_algorithm#C]XOR swap[/url]. So I guess you are being taught by a teacher that is still stuck in decades-old issues. This "save memory" thing was a problem before the 1970's and has been solved by hardware for decades. Unfortunately these old hacks are …

Member Avatar for Dave Sinkula
0
250
Member Avatar for bucsoldier03
Re: help

[inlinecode]getchar[/inlinecode] [inlinecode]fopen[/inlinecode] [inlinecode]fclose[/inlinecode] Try Googling "man <functionname>".

Member Avatar for jim mcnamara
0
120
Member Avatar for LordJayno

[inlinecode]atoi[/inlinecode] needs a pointer to a C-style string. [code]tree.Insert(atoi(b.c_str()));[/code]

Member Avatar for LordJayno
0
113
Member Avatar for christyj5

This is an array of 20 pointers to [inlinecode]Student[/inlinecode].[code]Student* list[20];[/code]Where do you allocate memory for each of these 20 pointers? Or did you instead mean to make an array of 20 [inlinecode]Student[/inlinecode]s? That would be like this.[code]Student list[20];[/code]But your use of [inlinecode]->[/inlinecode] notation would then need to be changed to …

Member Avatar for jim mcnamara
0
253
Member Avatar for dj_money

[QUOTE=winbatch][code]void catch_signal(int sig_num) { [COLOR=Magenta]cout<<"HEY! somebody cancelled me..."<<endl;[/COLOR] exit( 1 ); }[/code][/QUOTE]You shouldn't be putting standard output stuff in a signal handler. Search also for [inlinecode]sig_atomic_t[/inlinecode].

Member Avatar for brian63304
0
2K
Member Avatar for arun_kumar_c

[QUOTE=arun_kumar_c] my doubt is : how can we assign a string constant to a pointer.And when we assign like this is a character array with the name b[] is initialised to "abc"?[/quote]The pointer is assigned the address of an unnamed array which contains the string literal. [QUOTE=arun_kumar_c]and can anyone expalin …

Member Avatar for SpS
0
232
Member Avatar for Cudmore

[QUOTE=Cudmore]I simply don't like adding unnecessary headers becasue I don't use 95% of the crap that comes along with them, and it gets compiled with my program anyway...[/QUOTE]Well, uh, no, it doesn't. Is that your only reason? [QUOTE=Cudmore]Can I type cast?[/quote]If there's one thing to avoid when you're new, it's …

Member Avatar for Cudmore
0
197
Member Avatar for vicky_dev

This call is missing parameters.[code]printf("Address of x : %X, value : %d" );[/code]"If there are insufficient arguments for the format, the behavior is undefined."

Member Avatar for vicky_dev
0
300

The End.