jeezcak3++ 36 Newbie Poster

I did try and it came up with a few errors and I have no clue what to do. Thanks.

jeezcak3++ 36 Newbie Poster

This is a program to extract/compile car NAV .KWI extensions. Unfortunately, I do not know anything about Python though I will love to learn some time very soon. Could you help me compile this into an executable file for windows 7?

Will be reatly appreciated.

#!/usr/bin/env python
#
#       kiwi
#
#       Copyright 2009 Bert Vermeulen <bert@biot.com>
#
#       This program is free software; you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation; either version 2 of the License, or
#       (at your option) any later version.
#
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#       GNU General Public License for more details.
#
#       You should have received a copy of the GNU General Public License
#       along with this program; if not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.

import os
import sys
from getopt import getopt
import string
from datetime import datetime
import struct

EXTRACT_BUFSIZE = 1024 * 1024


def usage():
	print """usage: kiwi [-v|-x] [-o outputdir] -d <dvd directory>
  -v	list modules contained in the LOADING.KWI FILE
  -x	extract modules from the LOADING.KWI file
  -d	directory where the DVD is mounted
  -o	target dir to extract modules into"""
	sys.exit(1)


def …
jeezcak3++ 36 Newbie Poster

Thanks, guys! Now i understand.

I was assuming ... For instance, i pusH 2 more strings, "cigarettes" and "waiting" so we have 6 elements.

For( int i = 0; 0 < 6; 1)
if ( "Waiting" == "roller coasters")
no cout

second round
for ( int i = 1; 1 < 6; 2)
if( "waiting" == "waiting")
cout << "bleep"

and so on.

Have a good night guys!

jeezcak3++ 36 Newbie Poster

i am stuck! can someone re-write that FOR and IF part then explain to me? thanks much! every comments that you have left always teach me something.

btw, i am supposed to keep the code as simple as i can, right?

vector<string> words;
	words[0] = "roller coasters";
	words[1] = "waiting";
	words[2] = "people who talk on the phone while driving";
	words[3] = "wars";
	string temp;
	while (cin >> temp)
		words.push_back(temp);

	sort(words.begin(), words.end());


	for (unsigned int i = 0; i == words.size(); ++i)		
		if(words[i] == words[i+1]) //check next word if they match?		
		 cout << "bleep" << endl; //if so, bleep!

	return 0;
jeezcak3++ 36 Newbie Poster

:))

jeezcak3++ 36 Newbie Poster

<~~ another noob.

#include <vector>

save this in your include file folder as std_lib_facilities.h. don't forget to include in your code?

/*
	simple "Programming: Principles and Practice using C++" course header to
	be used for the first few weeks.
	It provides the most common standard headers (in the global namespace)
	and minimal exception/error support.

	Students: please don't try to understand the details of headers just yet.
	All will be explained. This header is primarily used so that you don't have
	to understand every concept all at once.
*/

#ifndef H112
#define H112 200608L

#include<iostream>
#include<fstream>
#include<sstream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
#include<stdexcept>
using namespace std;


template<class T> string to_string(const T& t)
{
	ostringstream os;
	os << t;
	return os.str();
}

struct Range_error : out_of_range {	// enhanced vector range error reporting
	int index;
	Range_error(int i) :out_of_range("Range error: "+to_string(i)), index(i) { }
};


// trivially range-checked vector (no iterator checking):
template< class T> struct Vector : public std::vector<T> {
	typedef typename std::vector<T>::size_type size_type;

	Vector() { }
	explicit Vector(size_type n) :std::vector<T>(n) {}
	Vector(size_type n, const T& v) :std::vector<T>(n,v) {}

	T& operator[](unsigned int i) // rather than return at(i);
	{
		if (i<0||this->size()<=i) throw Range_error(i);
		return std::vector<T>::operator[](i);
	}
	const T& operator[](unsigned int i) const
	{
		if (i<0||this->size()<=i) throw Range_error(i);
		return std::vector<T>::operator[](i);
	}
};

// disgusting macro hack to get a range checked vector:
#define vector Vector

// trivially range-checked string (no iterator checking):
struct String : std::string {
	
	String() { }
	String(const char* p) :std::string(p) {}
	String(const string& s) :std::string(s) {} …
jeezcak3++ 36 Newbie Poster

line 28: why is it testing for i != 0??? I is initialized to 1, so it will never be 0.

i was assuming that if i == 0, then words would make it i == -1, and that violated vector rules?

so that doesn't even need to be there? i keep getting runtime error.
if (i<0||this->size()<=i) throw Range_error(i);


for (unsigned int i = 0; i < words.size(); ++i)
//if i == 1 by now then why does it seem like  i < 0 after the line below? ;[
		if(words[i - 1] != words[i])
				cout << "bleep" << endl;
jeezcak3++ 36 Newbie Poster

This is a big problem:

for (int i = 0; i < words.size(); ++i)
     if (words[i -1] == words[i])

The first iteration of the loop 'i' will be 0. So when you replace 'i' with 0, you get this: if (words[0 -1] == words[0]) You're trying to access the -1th element of the vector, which does not exist!

yes, sir. that's what i thought when i got an error. i am trying to figure out. a little help?

int main()
{	
	vector<string> words;
	words[0] = "roller coasters";
	words[1] = "waiting";
	words[2] = "people who talk on the phone while driving";
	words[3] = "wars";
	string temp;
	while (cin >> temp)
		words.push_back(temp);

	sort(words.begin(), words.end());

// supposed to bleep if the input matches with words above
	for (unsigned int i = 1; i < words.size(); ++i)
		if(i != 0 || (words[i - 1] == words[i])) //check previous word if they match once sorted?
			cout << "bleep" << endl; //if so, bleep!


	
	return 0;
}

once again, thank you, all!

jeezcak3++ 36 Newbie Poster

yes, push_back() works. since i don't know how many strings i am going to add. thanks, guys!

jeezcak3++ 36 Newbie Poster

It goes "BLEEP" when one of these strings are input.

int main()
{
	vector<string> words();
	words[0] == "roller coasters";
	words[1] == "waiting";
	words[2] == "people who talk on the phone while driving";
	words[3] == "wars";

	string temp;
	while (cin >> temp)
		words.push_back(temp);

	for (int i = 0; i < words.size(); ++i)
		if (words[i -1] == words[i])
			cout << "BLEEP" << endl;

	return 0;
}
jeezcak3++ 36 Newbie Poster

Thank you all for your advices! I am very inspired.

jeezcak3++ 36 Newbie Poster

Thanks! i guess it was not easy for anyone at first?

jeezcak3++ 36 Newbie Poster

To be like me?

That is impossible. No amount of time will help you here. I'm sorry but I can't enlight you.

why is it impossible!? ;[ you could do it, why can't i?

jeezcak3++ 36 Newbie Poster

My goal is to "master" C++. I barely learned up to classes... destructors within a month from watching videos on youtube. My question is how much more do I have to learn to be like you? It seems like long way to go... I feel discouraged already after reading 7 chapters from "Teach Yourself C++ in 21 Das." There are times I felt stupid or I was just impatient to read thoroughtly, or the book is just too confusing. I always love programming and I want to learn different languages and I want to learn to write iPhone programs. I had to follow my career and gave up what I have always loved to do. Enlight me.

jeezcak3++ 36 Newbie Poster

nice site. but reading thru all that would rather have me getting over this.

jeezcak3++ 36 Newbie Poster

Try to send a reference of that function .

m = momo.operation(3, 4, &momo.addition);

syntax error, dude.

jeezcak3++ 36 Newbie Poster

Error message:
...error C3867: 'temp::addition': function call missing argument list; use '&temp::addition' to create a pointer to member

#include "stdafx.h"
#include <iostream>

using namespace std;

struct temp
{
	int addition(int x, int y)
	{return (x + y);}

	int operation (int x, int y, int (*functocall)(int,int))
	{
		int g;
		g = (*functocall)(x,y);
		return (g);
	}
};


int main ()
{
  int m;
  
  temp momo;

  m = momo.operation(3, 4, momo.addition);  // !!!???
  cout << m;

  cin.get();
  return 0;
}
jeezcak3++ 36 Newbie Poster

I am trying to download the full videos behind this flash player. Please investigate. Thanks!

HTTP link:
http://www.3dbuzz.com/vbforum/simplevideo.php?v=2064

<html>
<head>
<script type="text/javascript"> 
  window.focus();
</script>
</head>
<body>
<div style="position:absolute;left:0px;top:0px;width:100%;height:100%;" id="container">
</div>
 
  <script type="text/javascript" src="/vbforum/swfobject.js"></script>
  <script type="text/javascript">
 
 
  document.getElementById("container").innerHTML = '<a href="http://www.macromedia.com/go/getflashplayer"><img src="/images/sx/youneedflash480.jpg" width="640" height="516" border="0"></a>';
 
  /*var s1 = new SWFObject("http://www.3dbuzz.com/vbforum/mediaplayer4.swf","mediaplayer","100%","100%","9.0.124.0");
  s1.addParam("allowfullscreen","true");
  s1.addVariable("file","2064&q=0.mp4");
  s1.addVariable("streamer","rtmpe://vs1.3dbuzz.com/store/");
  s1.addVariable("type","video");
  s1.addVariable("bufferlength",10);
  s1.addVariable("autostart","true");
  s1.addVariable("start",);
  s1.addVariable("backcolor","0x383D43");
  s1.addVariable("frontcolor","0xEEEEEE");
  s1.addVariable("lightcolor","0xFFA518");
  s1.write("container");*/
 
  // Logan 2009-02-11
  
  var s1 = new SWFObject("videoplayerj.swf","mediaplayer","100%","100%","9.0.124.0");
  s1.addParam("allowfullscreen","true");
  s1.addVariable("videoid","2064&q=0");
  s1.addVariable("userid","233666");
  s1.addVariable("file","rtmpe://none/");
  s1.addVariable("id","mp4:none");
  s1.addVariable("bufferlength","10");
  s1.addVariable("autostart","true");
  s1.addVariable("start",0);
  s1.addVariable('backcolor','0x383D43');
  s1.addVariable('frontcolor','0xEEEEEE');
  s1.addVariable('lightcolor','0xFFA518');
  s1.write("container");
 
  </script>
 
</body>
</html>
jeezcak3++ 36 Newbie Poster

also in c++ its ctime and not time.h, for the header.

Thanks!

Also, I've been trying to research how to hop out of a function when a condition is met. Looking at the code above, if the player hasn't finished his moved in 15 seconds he would lose his turn. Then he should be kicked off move() function. Any ideas?

jeezcak3++ 36 Newbie Poster

You didn't post the entire program, so I assume you failed to include the header file that declared clock() function.

Here is everything. I try to rewrite Gunbound (gunbound.com) along as I learn.

#include "stdafx.h"
#include <iostream>
#include "time.h"

using namespace std;

void counter(int seconds)
{
	clock_t endTurn;
	endTurn = clock() + seconds * CLOCKS_PER_SEC;
	while (clocks() < endTurn){}
}

class Mobile
{
	public:
		Mobile(int startHealth, int startDamage, int moveDistance, int turnDelay):
		  Health(startHealth),
		  Damage(startDamage),
		  Distance(moveDistance),
		  Delay(turnDelay)
		  {};

		void move()
		{
		int countDown;
		for (countDown = 15 ; countDown > 0; countDown--)
		{
			counter(1);
		}


			int * uInput = new int;
						
			while (uInput - Distance < 0)
			{
				cout << "" << endl;
				cin >> *uInput;
			}
			delete uInput;
			uInput = 0;
		}

		void attack()
		{
			int uAttack = 0;
		}

		void defense()
		{
			int uDefense = 0;
		}
	private:
		int Health;
		int Damage;
		int Distance;
		int Delay;
};

class Weapons
{
public:
	void SingleShot()
	{
	}
	void DoubleShot()
	{
	}

private:
	int WeaponDelay;
};


int main()
{
	Mobile KnakMachine(1000, 250, 100, 600);
	KnakMachine.move();


	char f;
	cin >> f;
	return 0;
}
jeezcak3++ 36 Newbie Poster

Hi, I am new to the forum. I am in the learning process and I will stick around until I learn everything from you.

I try to create count down starting at 15 seconds. But when I compile, "clock identifier not found." I am !ondering the same thing, too. Perhaps can you explain how it works and give me correct it for me? I learn it faster by that way. Thanks!

void counter(int seconds)
{
	clock_t endTurn;
	endTurn = clock() + seconds * CLOCKS_PER_SEC;
	while (clock() < endTurn){}
}

void move()
{
	int countDown;
	for (countDown = 15 ; countDown > 0; countDown--)
	{
		counter(1);
	}
}
Ancient Dragon commented: Great Going! Used code tags correctly on very first post :) :) +36