Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You don't need command-line argumnents. Delete lines 24-33 because you don't have a file to open. On line 24 substitute stdin for fp. stdin is always an open file that represents keyboard input and can also be used for redirected files.

reverse(stdin);

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

when you type ./rev < numbers you are redirecting the contents of numbers into rev program. That is not what rev is expecting. Leave out the < symbol, just ./rev numbers (assuming numbers if the name of a text file)

Also I can't read a file one per line, and prints them back out in reverse order. I need output like:

A couple ways to solve that problem:

  1. Read the file backwards. This is a little more complicated than reading the file forwards as normal because you have to back up the file pointer before every read.

  2. Keep all the numbers in memory (linked list is good for that) then print them out backwards.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

why are you using stringstre3am? It's like hitting a nail with a slughammer.

What is variable n for? Just use the loop counter i.

if( line[i] == ' ')
{
   break;
}
else
{

}

that will give you only the first word in the line. What are you going to do with the rest of the words that nave not been processed?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If the columns are always in the order you posted, then after reading a line the data for Tuesday immediately follows the first semicolon. You can locate the position of the first semicolon by calling the function strrchr() (string.h). That function will return a pointer to the first occurrence of the semicolon (or some other character you specify).

beginning of loop

read a line
find position of first semicolon
increment the pointer returned by strrchr() by one to bypass the semicolon
now increment the pointer some more until the first non-space chacracter is reached
The pointer is now at the beginning of the data for Tuesday
Copy the data somewhere else to keep it for later printing or just print it on the screen

end of loop
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

All you have to do is call time() function (see time.h) to get current computer system time and date. Then you could have the data stored in files with the filename of the date it was written (you would want to include time if time of day is important). For example the filename could be "2013-3-24.txt" If you want the data for a specific date just format the filename with the given date.

Another way to do it is to have all the data in one file and date/time stamp each record. You didn't mention what kind of data you are talking about, so assume one row if the file for any given date/time. The time could look much like an Excel spreadsheet where columns are separated with commas or some other character.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

UNICODE only affects character strings, not bitmaps. For example, you need to convert the string literal "Hello World" by enclosing it in a macro _T("Hello World") (defined in tchar.h). You could also do it by putting capital L in front, such as L"Hello World". Using the _T or _TEXT macro (they are both the same result) is preferable because you can then compile the program with or without UNICODE and not change the code. If you use the L the string will always be UNICODE regardless of how the program is compiled.

Just because you compile a program for UNICODE doesn't automatically change the contents of any files. If your program is attempting to read a file that was written with UNICODE characters then the program will need to read it with wfstream. If the file was not written with UNICODE characters then the program will need to read the file with fstream and convert any strings (not bitmaps) to UNICODE before passing to functions that take UNICODE strings as arguments. There are functions that convert between UNICODE and non-UNICODE strings, or you could write your own function fairly easily if the language is English. In any event, attempting to typecase from char to wchar_t (or vice versa) does not work.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Why are you asking us if your program is correct? You should be able to determine that yourself by testing the code you wrote. If the program does everything the question wanted then it is correct. There may or may not be better ways to code it but that doesn't mean other ways are more or less correct then how you wrote it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

re-read Stop 1 carefully, your reverse() function does not meet the stated specification.

The function should take an open input file stream

That means the function referse() should have this prototype:

void reverse(ifstream& infile);

Next: Unless you were told otherwise by your teacher you should use std::string instead of charcter arrays, using std::string simplifies everything because it is less error prone.

Your reverse function is incomplete, it does nothing with the data that is read from the file. After a line is read the function must compute the reverse complement and print it to stdout (the screen).

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The problem is not your program but rather the largest number that can be stored in an integer. Look at the file limits.h that is supplied by your compiler and it will tell you the maximum value that can be stored in an unsigned long int. There is nothing you can do to change that value. You can gain a larger numbers if you use long long (a 64-bit integer). For some compilers the size of long is the same as long long, meaning that long long is a 32-bit integer just like long. Microsoft compilers use __int64 as a 64-bit integer.

Another possible solution to your problem is to use a large math library or write your own.

If you are using one of the MS-Windows compilers you should get MPFR library instead of GMP.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Don't expect anyone here to do your homework for you without lots and lots of $$$.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

argv[1] is a pointer to a string, if you want the first character in the string then it's argv[1][0]

this makes more sense anyway
argv[1][0] < '0' || argv[1][0] > '9'

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Of course it's identical to the way you would validate input from scanf(). argv is just an array of strings. argv[0] is always (if the os supports this) the name of the executable program and each string after that is whatever you put on the command line. If you execute your program named "test.exe" like this:
c:\test one two three <Enter key>

Then

  • argv[0] = "test.exe" (sometimes it also has the full path)
  • argv[1]= "one"
  • argv[2] = "two"
  • argv[3] = "three"
  • argv[4] = NULL

argc is an integer that indicates the number of arguments in argv, and it's value is always greater or equal to 1. In the above example the value of argc will be 4.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If the description is in the file it will be read into str[0]

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

MS-Windows knows nothing about opendir() etc -- those are *nix functions, not MS-Windows. You need to call FineFirstFile() and FindNextFile() which work something like the *nix functions. I have posted some code snippets that use those functions if you want to look at them. If you use .NET you can probably simplify the code (link).

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I've seen that happen every once in awhile -- when it happens just hit the Flag Bad Post button and ask a mod to delete the duplicate.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

unless you have one staring you in the face without a fence :)

<M/> commented: Hahaha :) +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

static class methods do not have an instance, they are always present in memory just like a normal global function. When you pass a function as a parameter the function is passed by address very similar to arrys and the address must be known at compile time, not runtime. The address of non-static class methods is only known at runtime when an instance of the class is created.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Did you provide the name of the database. You might want to read Oracle's documentation on that command to see if there are other requirements.

DROP DATABASE <database name>

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

DROP DATABASE will delete them all and the database.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

standard sql DROP TABLE <tablename>. You may have to drop indices first. DROP INDEX index_name

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I compiled it with Visual Studio 2012 and got these unresolved externals, which means you have not implemented some of the functions in that template.

1>SpellCheckMain.obj : error LNK2019: unresolved external symbol "public: __thiscall DoubleLinked<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::DoubleLinked<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(void)" (??0?$DoubleLinked@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@QAE@XZ) referenced in function _main
1>SpellCheckMain.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall DoubleLinked<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::~DoubleLinked<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(void)" (??1?$DoubleLinked@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@UAE@XZ) referenced in function _main
1>SpellCheckMain.obj : error LNK2019: unresolved external symbol "public: virtual bool __thiscall DoubleLinked<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::add(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?add@?$DoubleLinked@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@UAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main
1>SpellCheckMain.obj : error LNK2019: unresolved external symbol "public: virtual bool __thiscall DoubleLinked<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::contains(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)const " (?contains@?$DoubleLinked@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@UBE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main
1>C:\dvlp\ConsoleApplication3\Debug\ConsoleApplication3.exe : fatal error LNK1120: 4 unresolved externals

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Need BagInterface.h

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Post both header files so that we can try to compile it. If they are pretty big you might want to zip them up and attach them to your post.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

string has not been defined. You need to include <string> header file. Some compilers do that for you while others do not, so it's best to just get into the habit of always including <string> if you use it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

My happiness has definitely increased significantly since I quit smoking 13 years ago. (I'm thinking of the board game called "Careers" where you gain hapiness and fame points.) My fame points were not affected, but my happiness points sure were.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Be sure to post new code. I'm not showing you all the errors in your program. You should be able to find the rest by using the examples that I did show you. Compile the program, look at the first error message, fix it, then compile again. Fixing one error will likely resolve several error messages.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I thought I already answered your question. If you are passing an array of structures you don't need the & operator, just the name of the array because arrays are always passed as pointers. If you are passing a single structure then you need the & operator to make a pointer.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It's true we all die of something one day, but why hurry it?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

lines 69, 71, 79, 87 and 88: remove & from the parameters -- they are already arrays. When passing an array all you do is enter the name of the array, adding & operator makes it a pointer to the array (like wait**), which is not what you want.

line 81: scanf() needs a pointer to the variable where it is to store the data. So on this line you need the & to make ep a pointer, since all it is is a char.

line 104: wait->Front makes no sense because want is an array. Which element of wait do you mean? wait->Front is the same as wait[0].Front

line 107: I've already shown you how to fix that and other similar lines.

line 108: Same comment as for line 104 above.

anestistsoukalis commented: thanks +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Unlike C++, C language requires the data type on line 27, the symbol app by itself is not a data type. It should be struct app applist[2];

wait[] is an array of structures, not an array of pointers to structures. So you need to use the . operator instead of -> operator, something like this:

printf("%s , %d , %s",wait[Front].name,wait[Front].choice,wait[Front].phone)

anestistsoukalis commented: any ideas for the errors ? Thanks for struct and the operaton thing. +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It's been proven that a glass of wine a day will keep the doctor away -- it's heart healthy.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you have a full prior version such as Windows 7 then you can upgrade to Windows 8.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

MS-Windows can only be installed on either FAT32 or NTFS file systems. Your installation diskette should have given you the option to format the hard drive. Did you buy an upgrade version of Windows 8 or a new user version?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

My biggest regret is reading this thread :)

LastMitch commented: Nice One! +0
<M/> commented: oh, how mean ;) +0
ddanbe commented: Indeed, never regret. It's a waste of time! +0
Reverend Jim commented: Yet another thing we share. +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I only drink Bud Light on tap, and then only on special occasions such as going to really nice restaurant. I bought two special edition cases (24 bottles/case) two years ago when St Louis Cardinals baseball team won the baseball World Series, I stll have all the bottles, but drank some of the beer. The bottles I have are dated 2011 instead of 2006 as shown in the picture.

I don't care much for other alcoholic beverages, never did.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

very simple to add parameters, assuming you named the structure product

void create_product(struct product*p)
{
printf("\nPlease Enter The Product No. of The Product \n");
scanf("%d",&p->pno);
printf(\n\nPlease Enter The Name of The Product \n");
fgets(p->name, sizeof(p->name), stdin);
printf("\nPlease Enter The Price of The Product \n");
scanf("%f",&p->price);
printf("\nPlease Enter The Discount (%) \n");
scanf("%f",&p->dis);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Looks like all you have to do is call printf() instead of cout, replace cin with scanf(), change class to struct, and change the methods that are in the class to global functions. You may have to add a parameter or two to the functions in order to make that work.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Maybe this will help????

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Programs can run other programs, for example I could write a program that runs PrimePackster's program. So if his program was supposed to hit jack in the head, but missed and returned an error number from main() instead of 0 then my program would know that and take some action. In that instance the operating system passes the return value of main() from PrimePackster's program to my program. The return value from main() can also be used in batch files (MS-Windows) or shello programs (*nix).

PrimePackster commented: OMG! Thats a wonderful addition. Thanks For that..... +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 156: you are passing the wsrong type of data. selectionSort() wants an array of integers, not an asrray of structures. If you are tring to sort the class's data array (line 18) then remove the parameter to selectionSort() as it is not necessary. Just have selectionSort() sort data directly. If you want the array sorted by id then just use that field in the sort algorithm then when it's time to swap just swap the entire structure.

line 159: what is array a[]?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Are you able to change the table schema? If yes, then use one or more fields as the unique key. Auto id is nice, but not very usefor for preventing duplicate records.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You don't have to do anything in your code to prevent adding rows that contain duplicate key field(s), the database server to do that if you designed the table to require key fields to be unique values. All your program needs to do is catch the db server's exception. If the record already exists then an exception is thrown, line 32 will not get executed.

IMO you have too many checks inside the try/catch block. Inside the try/catch block all you need are the lines that actualy do the insertion, the database server will do the rest.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I heard it is illegal to convert YouTube to mp3 most likely because YouTube has a license to use those videos.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Example: Lets say you want to print out a multiplication table that has 10 rows and 5 columns. Rows are numbered 1 through 10 and columns numbered 1 through 5. The value in each column is the row number times the column number.

To print such a table you have to loop through each row, then inside that loop you have to loop through each column. It would be next to impossible to print the table if the two loops were reversed.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Since both are the same, it will probably depend on what "<lines of code>" contains.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

just use normal tar. WinZip for MS-Wiondows knows how to uncompress it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

But that won't prevent other programs from updating the data. The database server locks tables when doing updates, there is nothing you need to put in your code to do that.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I want to make sure that nothing can be accidentally altered.

How do you "accidentally" alter something in a program? If your program alters the data it's on purpose, not by accident. Want read-only? Just make sure your program doesn't attempt to alter the data.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

So you're replacing one subtle problem with another subtle problem. ;)

That's why I said there is no standard way to clear the keyboard buffer. Nonstandard way is to use _kbhit() from conio.h

while( _kbhit())
   getch();

Or on *nix look into termcap library.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You need to put quotes around FirstNumber and no quotes around variable names. Also put spaces where necessary so that FirstNumber and the value of x do not run together.

cout << "FirstNumber " << x << " SecondNumber " ;