2,384 Posted Topics

Member Avatar for trashed

First, end the structure definition with a semicolon:[code]struct CpuInfo { char vendor_id[50]; int family; char model[50]; float freq; char cache[20]; }[B][COLOR=Blue];[/COLOR][/B][/code][Dani - here's where I wish I had the ability to make the size bigger.] Here you need to carefully watch how you use parentheses:[code]if( [COLOR=Red]([/COLOR] cpuInfo = fopen("/proc/cpuinfo", "rb") …

Member Avatar for trashed
0
3K
Member Avatar for este77

Start at the beginning. Go from a blank source file to one with header(s) and a main function. Add some of the requirements that were heavily hinted. Post what you have and issues you are having.

Member Avatar for Dave Sinkula
0
165
Member Avatar for senthilselvi

Maybe [thread=286]this[/thread] or one of the other links shown at the bottom under "Similar Threads".

Member Avatar for Dave Sinkula
0
47
Member Avatar for Piotr_Machner
Member Avatar for SpS
Member Avatar for Narue
0
151
Member Avatar for kahaj
Member Avatar for kahaj
0
270
Member Avatar for btech

[QUOTE=btech]my question, which may be obvious is what is n? [/QUOTE]Whatever value you want to solve to. If you want the sum of squares from 1 to 5, it would be 5; if you want the sum of squares from 1 to 10, it would be 10. [QUOTE=btech]and what does …

Member Avatar for Dave Sinkula
0
159
Member Avatar for PeterX

[code]#include <stdio.h> int main() { int A = 5; double B = 10.5; double result = A / B; printf("result = [COLOR=Blue]%f[/COLOR]\n", result); return 0; }[/code]

Member Avatar for Dave Sinkula
0
120
Member Avatar for smithag261

[QUOTE=cscgal]What is an armstrong number?[/QUOTE][url="http://www.google.com/search?q=What+is+an+armstrong+number%3F"]What is an Armstrong number?[/url] [list] [*][url="http://homepages.cwi.nl/%7Edik/english/mathematics/armstrong.html"]http://homepages.cwi.nl/~dik/english/mathematics/armstrong.html[/url] [/list]

Member Avatar for Dave Sinkula
1
215
Member Avatar for compshooter

[QUOTE=compshooter][FONT=Comic Sans MS]I want to start by saying I did use the search function and I did read the fstream tutorial. But I didn't see the answer I need.[/FONT] :confused:[/QUOTE]Show us the code from your initial attempt and describe the shortcomings.

Member Avatar for bobobobo51
0
2K
Member Avatar for Mahen

>1. typedef int (*MYPROC)(LPTSTR); This declares an alias MYPROC which is a pointer to a function taking an LPTSTR as a parameter and returning an int. >2. hinstLib = LoadLibrary(TEXT("myputs")); This is a call to the function LoadLibrary, which is passed the parameter of TEXT("myputs") -- TEXT is likely a …

Member Avatar for Dave Sinkula
0
74
Member Avatar for smagee12

That was a pretty close attempt. [code]#include <iostream> #include <fstream> #include <string> using namespace std; int main() { [B]string[/B] arr[5]; int num; string first, last; fstream inData("file.txt"); [B]while ( inData >> num >> first >> last )[/B] { arr[num]= first+last; } for ( size_t i = 0; i < sizeof …

Member Avatar for smagee12
0
170
Member Avatar for SpS
Member Avatar for Narue
0
120
Member Avatar for mina1984
Member Avatar for server_crash

[url]http://www.parashift.com/c++-faq-lite/classes-and-objects.html#faq-7.8[/url]

Member Avatar for server_crash
0
164
Member Avatar for rufusOT
Member Avatar for prog-bman
0
397
Member Avatar for Acidburn

[QUOTE=sunnypalsingh]You need to allocate one more space for null character..... and after for loop add this line [code] encryption[45]='\0''; [/code][/QUOTE]That will be out of bounds.[QUOTE=Acidburn]any other ideas?[/QUOTE]If you intend to use standard C-style string functions, they do require null termination. Otherwise, you could use looping or a function such as …

Member Avatar for Acidburn
0
161
Member Avatar for nir_kar

[url]http://www.eternallyconfuzzled.com/tuts/bst1.html[/url] [url]http://www.eternallyconfuzzled.com/tuts/bst2.html[/url] [url]http://www.eternallyconfuzzled.com/tuts/bst3.html[/url]

Member Avatar for Narue
0
138
Member Avatar for Coach_Nate
Member Avatar for SpS

[Oooooh, when will these questions cease to poison new programmers...?] Yes. Hone your Googling skills if you are out of hints. [Bonus: Google the groups. Don't make me mention comp.lang.c (ooops!).]

Member Avatar for Paul.Esson
0
133
Member Avatar for Judas

[QUOTE=Judas]Is it possible to use a variable for a vector name [/QUOTE]To me it sounds like you may want a [B]std::map[/B].

Member Avatar for Dave Sinkula
0
97
Member Avatar for sapex

Scroll down to the bottom of this page and check out the Similar Threads. [URL=http://img118.imageshack.us/my.php?image=similar3db.gif][IMG]http://img118.imageshack.us/img118/59/similar3db.th.gif[/IMG][/URL]

Member Avatar for Drowzee
0
155
Member Avatar for Bears5051
Member Avatar for Bears5051
0
395
Member Avatar for Acidburn

[QUOTE=Acidburn]Not a problem as such but am i asking too much.... I can do a dynamic array for a 'int' but not for a multi dimensional array, can anyone help us out here?[/QUOTE]What is your intent -- what issue are you trying to solve?

Member Avatar for Lerner
0
223
Member Avatar for SpS

[QUOTE=sunnypalsingh]This works fine..where is 10 going??..how the compiler handles this??[/QUOTE]The same as it would any other useless code, such as:[code]int y, x = 10; x = 5;[/code]In the case of calling a function with a parameter, the value is still passed -- just like it would be if the value …

Member Avatar for chrisbliss18
0
158
Member Avatar for nikto

[QUOTE=nikto]No suggestion is too obvious.[/QUOTE]Try making a "debug" version of the project and start stripping away code until the bug goes away. Then put back in the latest removal that displays the bug, if you don't figure out what it is, and then post that code with any relevant "minimal" …

Member Avatar for nikto
0
160
Member Avatar for Ancient Dragon

[url=http://groups.google.com/group/comp.lang.c++/msg/f0985ee0d82129bb]I don't believe so[/url].

Member Avatar for Ancient Dragon
0
117
Member Avatar for Acidburn

One way (certainly not a great one): [code]#include <iostream> #include <cstdlib> #include <cstring> #include <ctime> using namespace std; int main() { cout << "this program will chose a name from a list randomly" << endl; char name[][5] = { "John", "Andy", "Matt", "Jane" }; srand(time(0)); char pick [ sizeof *name …

Member Avatar for Dave Sinkula
0
103
Member Avatar for Acidburn
Member Avatar for ramcfloyn

[QUOTE=ramcfloyn]any ideas?[/QUOTE]I'm not really sure, but it sort of sounds like you want to do something along this line... [code]#include <iostream> #include <bitset> #include <vector> #include <algorithm> int main() { static const char init[] = "abcdefghijklmnop..."; std::vector<std::bitset<8> > str(init, init + sizeof init); std::copy(str.begin(), str.end(), std::ostream_iterator<std::bitset<8> > (std::cout, "\n")); return …

Member Avatar for ramcfloyn
0
161
Member Avatar for m7r23

What's your question? [edit] "An enumeration comprises a set of named integer constant values. Each distinct enumeration constitutes a different enumerated type." [url=http://dev.unicals.com/c89-draft.html#3.5.6]typedef[/url]

Member Avatar for m7r23
0
142
Member Avatar for SpS

It sounds to me like that you want to do is like most implementations: provide header files and object files -- except that you may have put your source code in the header rather than in its own module. I'd recommend putting declarations in the header, putting the definitions in …

Member Avatar for Dave Sinkula
0
93
Member Avatar for stranger

Please read the [url=http://www.daniweb.com/techtalkforums/announcement8-2.html]Announcement[/url].

Member Avatar for Dave Sinkula
0
146
Member Avatar for SpS

My first reaction would be to say that [FONT=Courier New]sizeof[/FONT] is part of the language and go down that path... But one technique that might be used is to declare an array of a least two of the objects, declare two pointers to [FONT=Courier New]char[/FONT]; then cast & assign the …

Member Avatar for Stoned_coder
0
444
Member Avatar for SpS

Yes, you can simulate multiplication by non-powers-of-two with shifting and adding. For example, 11 = 8 + 2 + 1, you can build up from that.

Member Avatar for SpS
0
108
Member Avatar for bsdpowa

I, for one, generally do much better at answering questions if the code posted is complete, yet small and fully compileable, and demonstrates the problem.

Member Avatar for bsdpowa
0
369
Member Avatar for vikster

Post any code you have for your calculator program and your make file.

Member Avatar for bops
0
65
Member Avatar for Ancient Dragon

[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt__tempnam.2c_._wtempnam.2c_.tmpnam.2c_._wtmpnam.asp[/url][quote]Parameters prefix The string that will be prepended to names returned by _tempnam. [COLOR=Blue]dir The path used in the file name [B]if there is no TMP environment variable[/B], or if TMP is not a valid directory.[/COLOR][/quote]There is a standard [FONT=Courier New]tmpnam[/FONT].

Member Avatar for Ancient Dragon
0
272
Member Avatar for Domo

The function [FONT=Courier New]gets[/FONT] is not safe and should be [url=http://www.eskimo.com/~scs/C-faq/q12.23.html]avoided[/url]. As in, NEVER use it.

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

[QUOTE=Enzo]i mean using sockets in C++[/QUOTE]You didn't run across [url=http://www.ecst.csuchico.edu/~beej/guide/net/]Beej[/url]?

Member Avatar for Enzo
0
80
Member Avatar for Mystic_Skies
Member Avatar for Mystic_Skies
0
110
Member Avatar for kokopo2

I think [FONT=Courier New]strspn[/FONT] may be a better choice for your validator. First you ask for the size of the array, and that was fine. [COLOR=Blue]Then you want to allocate space to a pointer, adding one to make room for the terminating null.[/COLOR] [COLOR=Magenta]Then use the pointer much like an …

Member Avatar for bumsfeld
0
105
Member Avatar for Drowzee

[quote]I have already used #ifndef,#define, and #endif preprocessor commands to surround each header, but there are still many "LNK2005, already defined in *.obj" errors and "LNK2001, unresolved external symbol" errors.[/quote]Make sure your headers have only declarations and not definitions (except maybe if you are using templates). [url]http://www.eskimo.com/~scs/C-faq/q1.7.html[/url] [url]http://www.parashift.com/c++-faq-lite/templates.html#faq-35.8[/url] [url]http://www.parashift.com/c++-faq-lite/templates.html#faq-35.9[/url]

Member Avatar for Dave Sinkula
0
513
Member Avatar for sara.rythm

[QUOTE=vegaseat]2. use a macro like ... [code]// macro to swap two arguments of any type #define SWAP(x, y) ((x) ^= (y) ^= (x) ^= (y)) [/code][/QUOTE]That won't work for [I]any[/I] type. [url]http://www.eskimo.com/~scs/C-faq/q10.3.html[/url]

Member Avatar for Dave Sinkula
0
943
Member Avatar for Somfy

This may help: [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfiles/html/msdn_serial.asp[/url]

Member Avatar for Somfy
0
126
Member Avatar for janice_doe

[URL=http://img141.imageshack.us/my.php?image=contest18mf.jpg][IMG]http://img141.imageshack.us/img141/4877/contest18mf.th.jpg[/IMG][/URL] [URL=http://img222.imageshack.us/my.php?image=dsc017797hh.jpg][IMG]http://img222.imageshack.us/img222/2083/dsc017797hh.th.jpg[/IMG][/URL]

Member Avatar for Dave Sinkula
0
167
Member Avatar for kokopo2

[QUOTE=kokopo2]do any of u know how to extract a certain amount of bits from a parameter(instruction) and return the bits as a integer in a range . [/QUOTE][thread=17834]This thread[/thread] may be of interest.

Member Avatar for Dave Sinkula
0
1K
Member Avatar for shashankk

[QUOTE=shashankk]Can anyone pl. mail turbo c++ setup as attachment to << moderator edit: email snipped >>[/QUOTE][url=http://www.daniweb.com/techtalkforums/faq.php?faq=daniweb_faq#faq_rules]Forum Rules[/url][quote][B]Keep it on the site[/B] [COLOR=Blue]Please do not post asking for an answer to be sent to you via email.[/COLOR] Problems and their responses assist others who read them. Please refrain from responding to …

Member Avatar for kc0arf
0
385
Member Avatar for leonn

[url=http://www.daniweb.com/techtalkforums/announcement8-2.html][B]Announcement[/B][/url][quote][COLOR=Blue]This forum is meant for discussing programming languages in addition to exchanging code and algorithms.[/COLOR] However, it has become a problem where too many students are posting homework problems expecting a quick solution without ever trying for themselves. Not only does this constitute cheating, but it is very discouraging, frustrating, …

Member Avatar for kc0arf
0
99
Member Avatar for bops

[url]http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.4[/url] [url]http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.5[/url] [url]http://www.eskimo.com/~scs/C-faq/q12.2.html[/url] [url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1046476070&id=1043284351[/url]

Member Avatar for bops
0
254

The End.