Advertisement
Guest User

Stack Overflow help cpp

a guest
Aug 27th, 2011
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.42 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <cstdlib>
  3. #include <fstream>
  4. #include <ios>
  5. #include <iomanip>
  6. #include <iostream>
  7. #include <sstream>
  8. #include <string>
  9. #include <sstream>
  10.  
  11. using namespace std;
  12.  
  13. /*** These are the Variables I use for a weapon, they corrospond according to number in list: Wooden Shortsword is first in the
  14.  *** sSwordName Array, so it's lvl requirment would be 1 since it is first.
  15.  *** Idealy this is the way I want things to work... Unless anyone has a better idea, I am open to hear them. I can always
  16.  *** learn more, especially from others. ***/
  17. char sSwordName[10][25] =   {"Wooden Shortsword", "Bronze Shortsword", "Iron Shortsword", "Steel Shortsword", "Titanium Shortsword"};
  18. int sSwordLvlR[10] =    {1, 3, 5, 6, 10};
  19. int sSwordV[10] =       {5, 10, 18, 25, 50};
  20. int sSwordP[10] =       {10, 20, 40, 60, 100};
  21. int sSwordMinAtk[10] =  {0, 0, 0, 0, 0};
  22. int sSwordMaxAtk[10] =  {4, 6, 10, 14, 20};
  23. int sSwordAtkRate[10] = {0, 2, 3, 4, 6};
  24. int sSwordStrR[10] =    {1, 6, 11, 16, 22};
  25. int sSwordAtkR[10] =    {1, 6, 11, 16, 22};
  26. int sSwordIntR[10] =    {1, 3, 5, 8, 12};
  27.  
  28. /*** Now this is as close as I have been able to get to get this to work, sadly it is still off base...
  29.  *** I need it to take for example: Row 1 > Exclude Column 1 > Input Data > Assign to sSwordName[5][25] Array.
  30.  *** My issue is, finding a way to loop it where it takes all the cells in Row 1, ignores the first cell
  31.  *** (I think making it do like "\n" for it would work? Not sure) and then loop through the rest of the rows
  32.  *** repeating the same algorithm, Ignoring the first cell, inputting, assinging them to the variable arrays?
  33.  *** It is much much easier to edit item stats and add new items in Excel, than having to do it via code as you
  34.  *** may imagine..
  35.  *** I am pretty sure my code is far from what would be best, I bet it needs to be re-written a new way as well..
  36.  *** I would greatly appreciate Anyone who can help me accomplish this task.. It would really make my life
  37.  *** A lot easier, as well as make my project code considerbly shorter.. */
  38.  
  39. int main()
  40. {
  41.     int w;
  42.     double z;
  43.     string word;
  44.     string y;
  45.  
  46.     ifstream infile("Example.csv");
  47.     while (getline( infile, word ))
  48.     {
  49.         if (word.empty()) continue;
  50.         istringstream ss( word );
  51.         {
  52.             string val;
  53.             getline( ss, val );
  54.             stringstream( val ) >> w;
  55.             cout<<" "<<w;
  56.  
  57.             getline( ss, val );
  58.             stringstream( val ) >> z;
  59.             cout<<z<<endl;     
  60.         }
  61.  
  62.     }
  63.     system("PAUSE");
  64.     return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement