2,384 Posted Topics

Member Avatar for selsium

> 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

Member Avatar for Dave Sinkula
0
106
Member Avatar for VernonDozier
Member Avatar for Dream2code

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.

Member Avatar for Dave Sinkula
0
446
Member Avatar for rcbhat

[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.

Member Avatar for tuse
0
291
Member Avatar for Cloneminds

[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].

Member Avatar for Cloneminds
0
247
Member Avatar for lancevo3

[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 …

Member Avatar for lancevo3
0
154
Member Avatar for Cloneminds

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.]

Member Avatar for siddhant3s
0
122
Member Avatar for theashman88
Member Avatar for UrbanKhoja

[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. ;)

Member Avatar for Ene Uran
2
478
Member Avatar for Hiroshe

[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] …

Member Avatar for Hiroshe
0
10K
Member Avatar for GDICommander

[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?

Member Avatar for jephthah
0
302
Member Avatar for 9868

[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 - …

Member Avatar for Tom Gunn
0
91
Member Avatar for Humbaba
Member Avatar for Dave Sinkula
0
87
Member Avatar for mrnutty

A start and an end would have the same difference as 0 and clock() if clock() were resettable, no?

Member Avatar for mrnutty
0
118
Member Avatar for DoEds

Consider [URL="http://www.daniweb.com/search/search.php?q=currency+converter"]searching this site[/URL].

Member Avatar for Tom Gunn
0
359
Member Avatar for fourstar

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) …

Member Avatar for fourstar
0
2K
Member Avatar for ndeniche

[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 …

Member Avatar for ditz
0
1K
Member Avatar for timos

[QUOTE=athlon32;903320]"->" is used to access data members on the heap[/QUOTE]Or not.

Member Avatar for athlon32
0
126
Member Avatar for scru

[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 …

Member Avatar for jbennet
0
332
Member Avatar for coachHinesfan

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]

Member Avatar for Dave Sinkula
0
338
Member Avatar for yun

[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 …

Member Avatar for csurfer
0
284
Member Avatar for patrick k

[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 …

Member Avatar for Ancient Dragon
0
1K
Member Avatar for bharanidharanit

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 …

Member Avatar for Dave Sinkula
0
357
Member Avatar for kostasxx

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]

Member Avatar for Dave Sinkula
0
132
Member Avatar for Niner710

[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] …

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

[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... …

Member Avatar for Dave Sinkula
0
104
Member Avatar for giftalp

[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).

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

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 …

Member Avatar for athlon32
0
113
Member Avatar for MrNoob

[url]http://stackoverflow.com/questions/197614/k-r-question-need-help-understanding-getbits-method-in-chapter-2[/url]

Member Avatar for jephthah
0
113
Member Avatar for atman
Member Avatar for siddhant3s
0
123
Member Avatar for seemant_sun

[url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1048865140&id=1043284351[/url]

Member Avatar for Ancient Dragon
0
120
Member Avatar for Salem

[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 …

Member Avatar for GrimJack
1
196
Member Avatar for GrimJack

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 …

Member Avatar for GrimJack
0
716
Member Avatar for MidiMagic

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.

Member Avatar for MidiMagic
0
206
Member Avatar for Dave Sinkula

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?

Member Avatar for Nick Evan
0
106
Member Avatar for Fasola
Member Avatar for 0xCMD

[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]

Member Avatar for Dave Sinkula
0
174
Member Avatar for Steve00000
Member Avatar for san gabriel
Member Avatar for mirfan00
0
446
Member Avatar for adarshcu

Do you also think this should be an error? [code]printf("hello world");[/code]

Member Avatar for adarshcu
0
71
Member Avatar for TheBattlizer
Member Avatar for mj85

[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]

Member Avatar for jephthah
0
166
Member Avatar for seemant_sun

[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 ( …

Member Avatar for William Hemsworth
0
382
Member Avatar for nagu89
Member Avatar for Ancient Dragon
0
231
Member Avatar for monkey_king

[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 …

Member Avatar for monkey_king
0
217
Member Avatar for SallyJ
Re: Loop

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 …

Member Avatar for jesseb07
0
149
Member Avatar for shaggy7576

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]

Member Avatar for tux4life
0
137
Member Avatar for wnrqkflwnrqkfl

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 …

Member Avatar for Dave Sinkula
0
3K
Member Avatar for real_castilla

Is the input file opened? Is the read successful? Some error checking might help.

Member Avatar for real_castilla
0
134
Member Avatar for newbie_newbie

[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]

Member Avatar for newbie_newbie
0
148

The End.