2,384 Posted Topics
Re: > I changed strcpy to strcpy_s but no result. I checked for the data types of arguments passed , they are same. No difference. Really? char *strcpy( char *strDestination, const char *strSource ); See http://msdn.microsoft.com/en-us/library/kk6xf663.aspx errno_t strcpy_s ( char *strDestination, size_t numberOfElements, const char *strSource ); See http://msdn.microsoft.com/en-us/library/td1esda9.aspx | |
Re: [URL="http://c-faq.com/malloc/freeb4exit.html"]Related[/URL]. | |
Re: I'm late to this thread and haven't really been following it. [QUOTE=Dream2code;918747]suppose string="a|c|||f" strtok will return 3 fields ..a , c ,f but i need a,c,null,null,f (null indicates blank sting "")[/QUOTE] But this 'empty fields' bit reminded me of [URL="http://www.daniweb.com/code/snippet443.html"]a snippet or two[/URL] I'd done a while ago. FWIW. | |
Re: [QUOTE=rcbhat;915080]Hi, this is the code that I have to swap two strings[/QUOTE]Note also that you are not swapping strings; you are swapping pointers. | |
Re: [quote]main.cpp:36: error: no match for 'operator!=' in 'ids[x] != searchforID'[/quote]It's probably curious as to the details of how it should try to compare an [ICODE]int[/ICODE] with a [ICODE]string[/ICODE]. | |
Re: [QUOTE=lancevo3;915583]The addition operator should be overloaded to take two MyStrings, concatenate their text together, and return a new MyString that contains the result.[/QUOTE] Don't you want this function to be outside of the class? [code=c++]class MyString { // ... }; MyString operator+ (const MyString &lhs, const MyString &rhs) { return … | |
Re: What if the numeric input can contain negative values other than -1 such that sum becomes zero before the end of numeric input occurs? [I'm not a fan of forcing "supercompression" at the expense of readability and/or correctness, as it sometimes happens to instigate.] | |
Re: Or pipe the input from a file. | |
Re: [QUOTE=Ancient Dragon;398526][URL="http://www.jibjab.com/view/161370"]Some nasty prank[/URL] :scared:[/QUOTE]Hey! I was enjoying my nap. That wasn't funny. ;) | |
Re: [QUOTE=Hiroshe;914084]Is it possible in C to pass a 2d array without eather of the sizes known?[/quote]A short answer is "no". [url]http://c-faq.com/aryptr/ary2dfunc2.html[/url] [url]http://c-faq.com/aryptr/index.html[/url] [QUOTE=Hiroshe;914084][CODE=C] int array[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};[/CODE][code=c] printf("%d\n", array[3][2]);[/CODE][/QUOTE]Realize that [ICODE]array[3][2][/ICODE] is not an element in your declared array (even if [ICODE]somefunction[/ICODE] … | |
Re: [QUOTE=GDICommander;912314]Microsoft Visual Studio complains on runtime at the free(referenceArray[i]) [COLOR="Red"]in the do-while loop[/COLOR].[/QUOTE]Are you trying to free it more than once? | |
Re: [code=c]#include <stdio.h> int main(void) { int b[10][5] ; int (*q)[10][5] = &b ; printf("%p - %p = %d chars\n", q+1, q, (char*)(q+1) - (char*)q); printf("%p - %p = %d ints\n", q+1, q, (int*) (q+1) - (int*)q); return 0; } /* my output 0022FF68 - 0022FEA0 = 200 chars 0022FF68 - … | |
Re: [url]http://www.daniweb.com/tutorials/tutorial71858.html[/url] | |
Re: A start and an end would have the same difference as 0 and clock() if clock() were resettable, no? | |
Re: Consider [URL="http://www.daniweb.com/search/search.php?q=currency+converter"]searching this site[/URL]. | |
Re: Can you use the standard library? [code]#include <iostream> #include <ctime> int main(void) { using namespace std; // I'm being lazy struct tm calendar = {0}; calendar.tm_year = 2009 - 1900; calendar.tm_mon = 6 - 1; calendar.tm_mday = 30; time_t date = [COLOR="Red"]mktime ( &calendar )[/COLOR]; if ( date != (time_t)(-1) … | |
Re: [QUOTE=Nichito;410808]lets say you have the opportunity to choose between two women (men if you're a chick): one of them is the hottest thing you've ever seen, but as long as she/he opens her/his mouth, it is full of crap and idiotness... the other one is not too physically gifted... but … | |
Re: [QUOTE=athlon32;903320]"->" is used to access data members on the heap[/QUOTE]Or not. | |
Re: [QUOTE=jbennet;548159]i have been to A&E (thats the ER to yanks) umpteen times in my 18 years with various (serious) injuries and they have always helped me - when your life is at risk you are damn glad for the NHS.[/QUOTE]How is that even making a comparison? Final price after care … | |
Re: Much the same info as [URL="http://www.daniweb.com/forums/post901012-2.html"]#2[/URL]: [url]http://www.parashift.com/c++-faq-lite/operator-overloading.html#faq-13.14[/url] | |
Re: [url]http://www.kuzbass.ru:8086/docs/isocpp/dcl.html#dcl.enum[/url] [quote]The identifiers in an enumerator-list are declared as constants, and can appear wherever constants are required. An enumerator-definition with = gives the associated enumerator the value indicated by the constant-expression. The constant-expression shall be of integral or enumeration type. [COLOR="Red"]If the first enumerator has no initializer, the value of … | |
Re: [URL="http://clusty.com/search?query=man%20difftime"]man difftime[/URL] [edit][URL="http://www.daniweb.com/code/snippet367.html"]This[/URL] has similarities to the original topic. Slight nitpick: [QUOTE=Ancient Dragon;894881]IMO the easiest way is to convert both date strings into time_t [COLOR="Red"]integers[/COLOR], then just subtract the two integers.[/QUOTE]A [ICODE]time_t[/ICODE] is not necessarily an integer: [ICODE]time_t[/ICODE] (and [ICODE]clock_t[/ICODE]) "are arithmetic types capable of representing times;" where "[i]nteger and … | |
Re: I believe it is undefined per the standard. This is from n1124:[quote]7.19.5.3 The fopen function 3 The argument mode points to a string. If the string is one of the following, the file is open in the indicated mode. [COLOR="Red"]Otherwise, the behavior is undefined.231)[/COLOR] [quote]r open text file for reading … | |
Re: In C99 mode, with gcc 3.4.5: [code]#include <stdio.h> #include <stdint.h> #include <inttypes.h> int main() { int64_t value = 930342900243; printf("value = %" PRId64 "\n", value); return 0; } /* my output value = 930342900243 */[/code] | |
Re: [QUOTE=Niner710;893442]Hi, I am a newbie to C++ and want to know how to parse thru a binary file. I am having some trouble with some simple code. I have a sample binary file(test.bdb) that has "0069 0045 0089 0090" in the file. Here is my code for the file. [code] … | |
Re: [QUOTE=girl_pt;893203]I want to read the contents of a .txt file and the contents, for example, are: 1;london;7000;2000;3000;5000; etc i want to read them to a variable linked by adjacency lists I need to know how to do this for a paper work and any help is welcome. thx in advance... … | |
Re: [QUOTE=William Hemsworth;891893]>It can still be written more efficiently I'm curious, how could it get more efficient than that?[/QUOTE]A lookup table comes to mind (for a "speed" type of efficiency). | |
Re: The project is set up like this? [attach]10466[/attach] And you're sure that the code is #include-ing the header and not the source? [code]#include "fubar.h" // like this[/code] [code]#include "fubar.[COLOR="Red"]cpp[/COLOR]" // not like this[/code]That latter is a usual suspect for this type of error. As posted in #1, the code builds … | |
Re: [url]http://stackoverflow.com/questions/197614/k-r-question-need-help-understanding-getbits-method-in-chapter-2[/url] | |
Re: [url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1048865140&id=1043284351[/url] | |
Re: [URL="http://www.economist.com/daily/chartgallery/displaystory.cfm?story_id=13768993&fsrc=rss"]Who are the most enthusiastic voters in Europe?[/URL] [QUOTE]BRITAIN and the Netherlands kicked off the four-day process of electing members for the European Parliament on Thursday June 4th. It is one of the biggest democratic exercises in the world, with over 375m voters in 27 countries. But some voters lack … | |
Re: I have my own beliefs, but I do take interest in others'. Essentially this topic I find to be a pursuit of something other than its apparent intended purpose, but that is my opinion. I do enjoy this topic and the comments it receives nonetheless. I've followed some links previously … | |
Re: Pages that have some form of default audio to me fall in the NSFW category. So chalk me up in the "no audio ads" camp. | |
Is there a link for [url]http://www.daniweb.com/forums/spy.php[/url] roaming around the page somewhere? Or is that now in a limbo kind of like the IRC chat? | |
Re: I'd say [I]comment it well[/I] would be right up there. | |
Re: [url]http://c-faq.com/stdio/scanfhang.html[/url] [edit][url]http://groups.google.com/group/comp.lang.c/browse_thread/thread/3e3cbbd208c64cf6/19ae142d523723d7?ie=UTF-8&q=beast+scanf+group:comp.lang.c+author:torek#19ae142d523723d7[/url] | |
Re: [url]http://www.dinkumware.com/manuals/?manual=compleat&page=istream.html#basic_istream::getline[/url] | |
Re: Do you also think this should be an error? [code]printf("hello world");[/code] | |
Re: [url]http://en.wikipedia.org/wiki/Include_guard[/url] | |
Re: [url]http://c-faq.com/aryptr/dynmuldimary.html[/url] [url]http://c-faq.com/aryptr/ary2dfunc3.html[/url] [url]http://c-faq.com/aryptr/ary2dfunc2.html[/url] | |
Re: [code]#include <stdio.h> void showcolor(int color) { if ( color && 1 ) puts("violet"); if ( color && 2 ) puts("indigo"); if ( color && 4 ) puts("blue"); if ( color && 8 ) puts("green"); if ( color && 16 ) puts("yellow"); if ( color && 32 ) puts("orange"); if ( … | |
Re: [url]http://projecteuler.net/index.php?section=problems[/url] | |
Re: [QUOTE=monkey_king;879000]What is happening here especially the res.quot[/QUOTE]If you mean the [ICODE]do...while[/ICODE] loop, [code] do { res = div(value,base); *wstr++ = num[res.rem]; }while ( [COLOR="Red"]value=res.quot[/COLOR] );[/code] when the value of [ICODE]res.quot[/ICODE] -- resulting from the call to [ICODE]div()[/ICODE] -- is zero, the loop ends. Or rather, the value of [ICODE]res.quot[/ICODE] is … | |
Re: A "pointless" response might have been to do this: [code]#include <iostream> int main() { int k = 0; for ( int i = -1; i <= 3; i++ ) { k = i; [COLOR="Red"]std::cout << "i = " << i << ", k = " << k << "\n";[/COLOR] for … | |
Re: You'll have to let your function know about the character you want to print instead of doing this: [code] drawBar(i,[COLOR="Red"]i[/COLOR]);[/code] | |
Re: I might choose to read each line and then parse tab-delimited fields like this. [code]#include <iostream> #include <string> #include <fstream> #include <sstream> int main() { std::ifstream file("verging.txt"); std::string line; [COLOR="Red"]while ( getline(file, line) )[/COLOR] { std::cout << line << "\n"; // Display the whole input line. // Parse fields in … | |
Re: Is the input file opened? Is the read successful? Some error checking might help. | |
Re: [URL="http://groups.google.com/group/comp.lang.c++/browse_thread/thread/eeeee7678bc9335f?tvc=2&q=typedef+typename+template+group%3Acomp.lang.c%2B%2B"]A typdef must alias a complete type, which a template is not.[/URL] |
The End.