129 Posted Topics
Re: hi from what i can see ill explain whats going on [code] #include<iostream> #include<string.h> int main() { char* str="my name"; //char* means pointer so this creates a pointer to a character array called str. //str is initilised upon creation to the string "my name". As far as i know this … | |
Hi guys, Im working through accelerated c++ book and in chapter 4 ex 2 i had to build a program that displayed the square of ints (i) 1->100 inclusive using setw() to align the results. this i did ok and it works fine like 3 lines of code. However in … | |
Re: Hi, I get the feeling your wanting some keyboard interaction here? Depending on the graphics API your using you have to use some functions in them to enable and use text. Its quite a bit more involved than normal console as an example please look at this link which is … | |
Re: Hi, To store the books thats a valid approach but manually coding all the book names is a bad idea i think. i suggest scanning a directory and geting the file names if they are in one directory see link -> [URL="http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1046380353&id=1044780608"]LINK[/URL] for a few possible ways to do this. … | |
Re: [quote] 5.6 - Multiple Return statements in a function. I heard that you can have multiple return statements within a single function. Could someone show me an example of this, and explain to me how the program knows not to exit the function after the first one? ...also why would … | |
Hi all, Im working on the design of a function at the moment and im not sure if the if statement i want to do is safe. Ill start with the data structures i have as this is where the problem could come from. (simplified with relevent bits only) [code] … | |
Re: If you are talking about programming a router or similar to which you can write to the processors program instructions memory, it all depends on the processor in use. such as most 8051's (its definately not one of those) only support regular C (some enhanced 8051's have native java support), … | |
Re: heya there are two options here for you, you can declare a character and read with cin or tell cin that you want only a character such as below [code] char myChar; cin>>myChar;//cin sees a char variable so reads only a char //or myChar = cin.get(); //the same as getchar … | |
Hiya, Im trying make a simple cards game and i was wondering how in c++ can i use the characters ♠ ♣ ♥ ♦ , i think it would be betetr than me printing out the words each time, Are these in some extended character set anywhere? i tried googling … | |
Re: Jackie, If you wish a simple method for checking if the user has entered any numbers instead of just characters you can use the isalpha() function. it accepts a single character as input so you could make a check function something like,.. [code] bool checkForNoNumbers(string &str) { char* temp;// temp … | |
Re: Ok what Danny is saying that you currently have 2 mains in the same project i agree, I would like to suggest that even for trivial examples try using more meaningful names as this will be handy later on. What he suggests is that you currently have 2 sets of … | |
Hi guys, As some of you may know im working on learning more c++ and trying to become a good programmer, iv got things like classes, function pointers and template classes under the belt as far as i can see (although to be honest i have never found a place … | |
Re: Ok iv only had a short look at this but looking at the while loop [code] while (infile) { // processing statements grossPay = hours * rate; taxPayable = grossEarnings * 0.15; medicalLevy = grossEarings * 0.01; netEarnings = grossEarnings - taxPayable - medicalLevy; totalGrossEarnings = totalGrossEarnings + grossEarnings; totalTax … | |
Re: Also just like to point out another flaw [code] fin.open("getfromthisfile.txt"); if(fin.fail()) { cout << "Input file opening failed.\n"; exit(1); } fout.open("sendtothisfile.txt"); if(fin.fail()) { cout << "Input file opening failed.\n"; exit(1); } [/code] WHY are you checking if the istream failed again after opening an ostream, bad use of copy and … | |
Re: [QUOTE]Is there any way to get a value on a matrix in a list exactly like "matx[3][4]" with square brackets like default C matrix [/QUOTE] The [ ] operator can be overloaded but ill admit im not very strong on operator overloading so i dont know how to do it … | |
Re: Ok for this i would recomend making a key making function something like the following [code] void makeKey(char *keyBuff, int keyLen) { unsigned char randomKeyByte;//var to hold random key if(strlen(keyBuff)<keyLen)//if key buffer is to small we have a problem { cout<<"Key buffer is to small"<<endl; cout<<"Requested key of size "<<keyLen; … | |
Re: Hey For this problem i have devised a simple solution that i think meets your needs please consider the following. [CODE]#include <iostream> #include <cctype>> using namespace std; int main() { char ch; char compare; cout << "Enter any character, lowercase or uppercase: "; ch = cin.get(); if(isalpha(ch))//check the character is … | |
Hi everyone, I'm not so sure if this belongs in here or in computer science but I think as I want to use c++ this may be the place. I was wondering if anyone could point me towards some tutorials/references or books on methods for approaching the design of larger … | |
Re: Just looking at this very complex for loop that whole thing looks to be a for loop condition so where is the code that is executed upon each iteration? Try breaking it down and see if thats what you expected/wanted | |
Re: [QUOTE]error: 'itoa' was not declared in this scope[/QUOTE] to use itoa ensure you include cstdlib (see below) [code] #include <cstdlib> [/code] this should solve the problem allowing you to += the chars into the string | |
Re: the character '' ? it would be [code] cout<<'\'<<endl; //just the single character cout<<"c:\\someFile"<<endl; //used as part of a string //second prints to console "c:\someFile" [/code] edit: ..... beaten to the punch again :'( lols | |
Re: Ok i dont know if this s really the best way to help here but i have a couple of classes i made a while ago. one C_Day is a class which holds a list of tasks to be done on that day which are stored as a linked list. … | |
Re: Yeah basically thats what they are saying and i have found additional formating things and some bugs in functionality. my code below | |
Re: Hi i tried ur code, i couldent get it to even see the pos struct with 2 cpp files (as i expected) so i made the above code as a .h file and then added a #include to it in the main and then it allowed me to use the … | |
Hiya Im trying to make a few efficient maths classes that will optomise using SIMD SSE or SSE2 if the target CPU supports those SIMD variants or failing to support either use a normal CPU bound c++ version. The issue im having is that i want to have for example … | |
Re: Have you tried something like [code] FILE *h_file; int numberStartPos; int numberEndPos; char temp; string result; /*loop from start pos to end pos reading bytes (im assuming ascii chars) and appending them to the string result*/ for(int x = numberStartPos; x<numberEndPos; x++) { fseek(h_file, x ,SEEK_SET); //seek to the next … | |
Heya Thanks for taking the time to look at this, i would like some people to review my curent project which is written in c++ using visual studio 2008. Although in VS08 it does not use anything that makes it dependant on it (i dont think) i just wanted to … | |
hey, Just starting to learn how to use classes in c++ and when i try to split my class out of the main code and put it in a headder or a headder and a second source file dev C++ is giving me loads of errors and i dont know … | |
Re: Heya, new to c++, just finished a bit of c programming and ur reply really helped thanks nobody told me about the std:: bit not even the book i was using ...but it works now cheers,.... by any chance could you advise when i ened the std:: bit in my … |
The End.