2,045 Posted Topics
Re: You need to escape the backslashes with another backslash (just like using a backslash to escape double quotes and the like): [icode]system("c:\\new\\ram.bat"); [/icode] | |
Re: [quote]Write a program that will first fill two out of three parallel arrays (local to the main function) with user-supplied data and then give users the choice to query the parallel arrays. The first array is as follow: char title[SIZE_ROW][SIZE_COL]={"Intro to Calculus", "C++ Programming", "Java Programming", "Intro to Psychology", "Intro … | |
Re: Why have the while loop at all? You have the length of your input on line 17 and all the loop on line 20 is going to do is ask for more input. Use a for loop and march through the string by index (in [icode]string mystr = "abcd";[/icode] mystr[0] … | |
Re: Read [icode]('A' <= && c <='F') [/icode] over. Something's amiss. | |
Re: Use strcpy to copy those values into the character array: [code] #include <cstring> //to access strcpy switch(col) { case 1: strcpy(text,"0x00000000"); break; //etc. } [/code] You can only assign text to a character array in the manner that you are trying when it is first declared. | |
Re: Does it rely on a file that it looks for in the same directory as the application? If so you need to copy that file from the debug to the release folder. | |
Re: I would take a minute or two and get the formatting all straightened out (get stuff tabbed in and line up all the opening and closing braces with each other) and the answer should be evident. (Post 2000)-- ignore this | |
Re: It's doing exactly what you asked it to. You're having the program look for when the text has changed in the textbox (so if you type in any characters that event is firing with each one) and outputting the results to the file. You are getting the text of entire … | |
Re: You don't have to go through all this as Write() has an overload that takes a string directly. If you had to go the route you planned you can use the ToCharArray() method of the string to get the array that you need. | |
Re: [quote=Anarionist][code] //or if you wanted to call a function or variable without declaring an object //just like namespaces foo::color(RED); cout<<foo::x; [/code][/quote] This only works if the function or member variable is static so ignore that bit for a moment (see below for a link to more info). Otherwise you need … | |
Re: [QUOTE=somaja;1169097]i included these libraries: #include<iostream> //for i/o #include<fstream> //for opening files #include<string> //for strings #include<iomanip>[/QUOTE] Where does ReadData() come from then? I don't think that's included with any of these. | |
Re: Line 99: There's an issue with case sensitivity here. In one file you include the header as "Point.h" and in main you include it as "point.h". If that's not the case make sure that your class cpp is getting compiled before your main cpp. | |
Re: It's initializing a character array of length 1 with the null character. | |
Re: A better way (though not the only way) to write it would be with a nested for loop: [code] for (int x = 0;x<=384;x++) { for (int y = 0;y<155;y++) { //this way you wouldn't need the int x=0 and int y=0 at the top [/code] because even if you … | |
Re: Use Int32::TryParse instead of the Convert call. It's safer and it will return false if it fails versus throwing an exception. You'll have to have a tracking reference [icode] int % aout = a;[/icode] to get the value back from TryParse, but declare "a" as a regular old int and … | |
Re: Use a StreamReader object (in System::IO) to read in the text from the given filename as a string. You may be able to send it right to the textbox from there. Here's the code I used: [code] private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { OPEN DIALOG StreamReader^ sr = gcnew … | |
Re: You need dynamic_cast. For example [code] (dynamic_cast<Class1*>(b))->GetValue() [/code] will get you the value of 1 in your code. Use the dynamic_cast to convert your Base * object to a Class1* type (essentially you're just moving down the class hierarchy hence you used dynamic_cast and "downcast" the object) and now that … | |
Re: Replacing line 29 with [icode] cin.getline(charName,50);[/icode] would be the best way to go. The cin.ignore helps in the situation where there are newlines ('\n', resulting from pressing enter after your input) left in the input stream. Since you would have the cin.getline statement first and then the cin >> there … | |
Re: First, you need to learn how to format your code. Good that you got the code tags but what you have looks terrible and is hard to follow. Give this article a read: [url]http://www.gidnetwork.com/b-38.html[/url] Secondly, your switch syntax is completely wrong, you need colons after the cases not semicolons: [code] … | |
Re: Line 16, try initializing part_sum and tot_sum to 0. | |
Re: [quote][icode]gets(String) ;[/icode][/quote] [u]Don't[/u] recommend the use of gets. It can take input until the cows come home and tries to write it all to that array--> overrun. Use fgets instead. | |
Re: [icode] #include <time.h> [/icode] and you should already have stdlib because of rand(). At the top at some point before line 18 call [icode]srand((unsigned)time(0)); [/icode] to seed the random number generator using the current time (and converts that value to one acceptable to srand). A couple of little things: main() … | |
Re: [quote]What makes you think Narue is female? (s)he admits (s)he is a witch, so (s)he could be either or both.[/quote] [quote]But her profile says "Code Goddess"! And Dani is the most powerful on Daniweb . . the God of Daniweb. I'm convinced. [/quote] [U]Don't[/U] make me rethink my entire worldview. … | |
Re: I shouldn't reply since you keep bumping this... So what do you believe you have left to do? Looks to me like it's putting stars to head up the front of each of the rows and that you have to push some off the end those rows that receive extra … | |
Re: [code] void swap(Record a, Record b) { Record temp = a; a = b; b = temp; } [/code] is not swapping the structs (as copies are being made). Try passing them by reference [icode]swap(Record & a,Record & b) [/icode] or by pointer. | |
Re: I don't understand what you are trying to do on lines 14 and 16. The >> operator does not work with entire vectors like that. Also what's going on with your loops on 18 and 22? Check those loops by hand, if "i" starts at zero and it evaluates the … | |
Re: Frank Fontana? From Murphy Brown (sorry that's the first thing I thought of when I read that)? Wager a guess as to who's getting an alarm system as a very late holiday gift? | |
Re: You are trying some creative coding there. You need to make Yes a string and then compare it to "yes." For example, [code] cout <<"Enter another pt? "; cin >>Yes; if(Yes == "yes" || Yes == "Yes") //and any other variants you want { //do something } [/code] The fact … | |
Re: You got the code tags backwards, put them around your code and don't put them around your question. There's still time to edit. | |
Re: Does [URL="http://geekswithblogs.net/renso/archive/2009/10/21/how-to-set-the-windows-path-in-windows-7.aspx"]this link[/URL] help? (add your Borland directory to the path) | |
Re: [quote][icode]gets(String) ;[/icode][/quote] [u]Don't[/u] recommend the use of gets. It can take input until the cows come home and tries to write it all to that array--> overrun. Use fgets instead. | |
Re: The extra '\n' from where you take in the number and press enter gets stuck in the input stream and carries down to your other prompt causing the wrong instruction error to come up (since '\n' !='y'). Here's a couple of tutorials to get you through the problem. Particularly read … | |
Re: Use the sprintf function. It would look something like sprintf('apple%d.tiff',j); (I don't run matlab any more so I can't test it out) inside of a nested for loop [code] Outer for im1 = imread(sprintf('apple%d.tif',i); Inner for im2 = imread(sprintf('apple%d.tif',j)); Write corr2(im1,im2); into an i by j matrix (zeroed out before) … | |
Re: Give [URL="http://www.daniweb.com/forums/thread244347.html"]this thread[/URL] a read. It goes into the specifics of why using scanf in the manner that you have isn't a good idea. Use fgets instead. Simple syntax: [icode] fgets(line,sizeof(line),stdin); [/icode] | |
Re: In your second example you haven't noticed the additional space that's being put in front of the word. This could very well be any junk character because when you reference [icode] str[strlen(str)] [/icode] you overstep the bounds of the array. Remember, if your string is length 3 you're only going … | |
Re: Think of each letter of the alphabet as a number from 1-26. So a-z are just 1 thru 26. And aa = 1x26 + 1, ab = 1x 26 + 2, etc. zz = 26x26+26 = 702, aaa = (1x26x26)+(1x26)+1 = 703. So basically you would just parse the digits … | |
Re: Check out the functions in ctype.h (include it as <cctype>). It has an [icode] ispunct() [/icode] function which you could use as you're moving through your array. See [URL="http://www.cplusplus.com/reference/clibrary/cctype/"]this for a reference[/URL] to all the functions in that header. | |
![]() | Re: [code] Example_Struct * Foo::GetStructBar() { return structBar; } char * Foo::GetBar() { return bar; } [/code] Provided you have [icode] Example_struct structBar[10]; [/icode] (your array length here obviously) and [icode] char * bar[/icode] declared in your class. Make them Example_struct * and char * return variables in main also. |
Re: Your parameters of your prototype don't match the parameters of your function definition. You don't need the x,y,z that's going to be passed in,the function doesn't care about that, you need something like line 39. However, unlike 39 since it's a prototype you can omit the Array word, but leave … | |
Re: One other thing, might be an issue: [quote=Wikipedia] The exponent on a variable in a term is called the degree of that variable in that term, the degree of the term is the sum of the degrees of the variables in that term, and [COLOR="Green"]the degree of a polynomial is … | |
Re: Remove all the stuff related to gs_A,B,C,D. You don't need them. You are passing in the thresholds for the grades, so use them. If I were to say, ok, answer in terms of s1, what is the highest grade acceptable for a B? What is the lowest grade (in terms … | |
Re: [quote]There's a guy with 3 legs =) [/quote] I thought his associate was attempting to moon the Google vehicle as it went by but missed the chance. Does anyone know what these cars look like? I've never seen one. | |
Re: In that thread you specified, (I believe) Narue was saying that it was not a legal specifier for use with [I]printf[/I]. That is the correct format specifier for a double in [I]scanf[/I]. I thought she gave an explanation for that asymmetry at one point but I may be thinking of … | |
Re: Wrap from lines 6 thru (and including) 43 in a do/while loop. Instead of having the if and else if use c == 'y' as your condition of your do/while. | |
Re: What was the old way that you were using? I don't think there's anything wrong with the way you are reading input in this case. You could make the coef be a dynamically allocated array so it doesn't have to be set at 11. | |
Re: I might think of it this way: For your second example you have 3/4 chance it will roll 2 and 1/4 chance of rolling a 6. For this specific case, get a random number between 0 and 4(exclusive of 4). If you pick 0,1, or2, you've rolled 2 and if … | |
Re: OP seems to have record being passed in as a [icode]char*[/icode]. Shouldn't it pass in as [icode] struct PATIENT * record [/icode]? | |
Re: Dereference s before you try to get the c_str() method: [icode] c = (*s).c_str(); [/icode] since s is a pointer to string not a string. Or [icode]c=s->c_str();[/icode] will work too I just thought the other form was more illustrative for your benefit. Also, strlen won't give you the length of … | |
Re: Try it with numbers first if you are stuck: 1 232 34543 Then figure out how to translate from the numbers to the letters of the alphabet. Here's a hint:[url]http://web.cs.mun.ca/~michael/c/ascii-table.html[/url] | |
The End.