2,384 Posted Topics
Re: 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...? | |
Re: [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. … | |
Re: Some light reading: [url]http://ldeniau.home.cern.ch/ldeniau/html/oopc/oopc.html[/url] :p | |
Re: 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. | |
Re: [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)? | |
Re: 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 … | |
Re: 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, … | |
Re: 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? | |
Re: [url=http://groups.google.com/group/comp.lang.c/msg/88ec0cd40f400cb7]FYI[/url] | |
Re: [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 … | |
Re: It looks like you're trying to use some nonstandard I/O. Compiler/OS? | |
Re: 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] | |
Re: [code]system([COLOR=Blue]"dir/B *.txt >>a.txt"[/COLOR]);[/code] | |
Re: Do you know how to input a line of text and parse it? | |
Re: Copying to .NET forum. | |
Re: Copying to .NET forum. | |
Re: I'd start by googling for an API on the target and its OS. | |
Re: 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] | |
Re: 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] | |
Re: 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 … | |
Re: Possibly. [url]http://www.daniweb.com/techtalkforums/announcement8-2.html[/url] | |
Re: [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 … | |
Re: [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. | |
Re: 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 << … | |
Re: 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. | |
Re: [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 … | |
Re: Arrays are zero-based. If you have [inlinecode]T array[10][/inlinecode], it may be indexed from 0-9, not 0-10. | |
Re: 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'); … | |
Re: [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 … | |
Re: You should be passing a [i]pointer[/i] to the first character of the string. | |
Re: [QUOTE=bucsoldier03]how do i get to the tutoriols[/QUOTE][url]http://www.daniweb.com/tutorials/forum21.html[/url] | |
Re: [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. | |
Re: [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. | |
Re: 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). | |
Re: I thinking of a number between 223 and 367 -- what is it? [Translation -- do you think you could be a little more specific?] | |
Re: [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 … | |
Re: 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. | |
Re: [url=http://www.cppworld.com/forum/index.php?showtopic=1041&st=0&#entry6838]Same answer[/url] to the same question. | |
Re: [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++ ) … | |
Re: [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. | |
Re: 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 … | |
Re: [inlinecode]getchar[/inlinecode] [inlinecode]fopen[/inlinecode] [inlinecode]fclose[/inlinecode] Try Googling "man <functionname>". | |
Re: [inlinecode]atoi[/inlinecode] needs a pointer to a C-style string. [code]tree.Insert(atoi(b.c_str()));[/code] | |
Re: 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 … | |
Re: [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]. | |
Re: [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 … | |
Re: [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 … | |
Re: 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." |
The End.