Friday, October 16, 2009
Binary Search tree with insert delete, print option C
Simple Linked Stack
Simple Linked list
c search replace string example
#include
int main()
{
char replaceitem[100];
char str[300];
char newstr[300];
char searchitem[100];
int flag=0;
int i=0;
int index=0;
int j=0;
int k=0;
printf("Enter String\n");
fgets(str,300,stdin);
printf("Enter Search item\n");
fgets(searchitem,100,stdin);
printf("Enter replacement item\n");
fgets(replaceitem,100,stdin);
for( i = 0;i < strlen(str); i++) {
for(j=0;searchitem[j]==str[i+j];j++){
if(searchitem[j+1]=='\0')
break;
}
if((j==strlen(searchitem)-1)){
for(k=0;k
flag=1;
}
i+=strlen(searchitem)-2;
}
if(flag==1){
flag=0;
continue;
}
newstr[index++]=str[i];
}
newstr[index]='\0';
puts(newstr);
return 0;
}
combine 2, 32 bit no to create 64 bit no C
#define concat(val,num2)val=val|num2
#define call(val,num2) shift(val);concat(val,num2)
int main()
{
int num1;
int num2;
unsigned long long val;
scanf("%d",&num1);
scanf("%d",&num2);
val=(long long)num1;
call(val,num2);
printf("%lld",val);
}
Tuesday, April 7, 2009
How to change color of BOX2D objects
In about 1060 line number
for (s = b.GetShapeList(); s; s = s.m_next)
{
if (b.IsStatic())
{
DrawShape(s, xf, new b2Color(1, 1,1), core);
}
else if (b.IsSleeping())
{
DrawShape(s, xf, new b2Color(0.0, 0.0, 0.9), core);
}
else
{
DrawShape(s, xf, new b2Color(0.8, 0.7, 0.5), core);
}
}
change the values in new b2Color(0.4, 0.4,1) to change the color
Sunday, March 1, 2009
How access dll from flex
access dll files from flex.How ever one thing you can do is to
create webservice in asp .net and call that webservice from flex program.
You can do the same with webservice, httpservice, Remoting (using remote objects)
The best example i can find in adobes site here
http://www.adobe.com/devnet/flex/articles/communicating_flex_dotnet.html
communicating_flex_dotnet_06.html
you can use fluorinefx http://www.fluorinefx.com/ for flex .net remoting
in addition you can use weborg
http://www.themidnightcoders.com
example :
http://www.adobe.com/devnet/flex/articles/communicating_flex_dotnet_06.html
httpservice (For simple data transmission)
webservice (Datain Xml Format)
Remoting (Pass objects)
Another method through which an swf can call a dll is through External interfaces.
You can load the swf into your .net program. Then using external interface swf can communicate with c#.
I found a good Example here
Here is an another method using ActiveX component by srinivas
here
ttp://livedocs.adobe.com/flex/3/html/help.html?content=19_External_Interface_10.html
Thursday, February 26, 2009
Augmented Reality in flash
http://www.boffswana.com/news/?p=392 //includes source
http://www.mikkoh.com/blog/?p=182 //good example with source
http://www.libspark.org/wiki/saqoosha/FLARToolKit/en
http://createdigitalmotion.com/2009/02/10/opencv-motion-tracking-face-recognition-with-processing-im-forever-popping-bubbles/
http://createdigitalmotion.com/2009/01/07/happy-new-year-with-augmented-reality-flying-words-of-wisdom/
http://www.boffswana.com/news/
http://saqoosha.net/2008/08/31/1221/
http://blog.tarotaro.org/archives/category/ar/flartoolkit
http://ubaa.net/shared/processing/opencv/
http://www.timovirtanen.com/category/flash/
Later I will try to correct errors in the articles
Sorry for bad english.
Saturday, February 21, 2009
Traversing and adding file structure to a tree node
using System.Text;
using System.Threading;
using System.IO;
public void ListDir(string src, TreeNode d){
try{
DirectoryInfo dinfo = new DirectoryInfo(@"" + src);
FileInfo[] finfo = dinfo.GetFiles();
for (int j = 0; j < finfo.Length; j++)
{
d.Nodes.Add(@"" + finfo[j].Name);
}
DirectoryInfo[] dname = dinfo.GetDirectories();
TreeNode[] treend = new TreeNode[dname.Length];
for (int i = 0; i < dname.Length; i++)
{
treend[i] = new TreeNode(dname[i].Name);
d.Nodes.Add(treend[i]);
}
for (int i = 0; i < dname.Length; i++)
{
ListDir(dname[i].FullName, treend[i]);
Thread.Sleep(5);
}
}
Listing Logical Drives
int i = 0;
while (i < dinf.Length)
{
MessageBox.show(dinf[i]);
}
Create XML file using C#
using System.Data;
using System.Drawing;
using System.Xml;
using System.IO;
//code
XmlTextWriter xmlWriter = new XmlTextWriter("temp.xml", System.Text.Encoding.UTF8);
xmlWriter.Formatting = Formatting.Indented;
xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
xmlWriter.WriteStartElement("root");
xmlWriter.Close();
// creation complete
doc = new XmlDocument();
doc.Load("temp.xml");
XmlNode newNode = doc.CreateNode(XmlNodeType.Element, "firstnode", ""); // creating Node
newNode.InnerText = “Content”; // set your content
doc.DocumentElement.AppendChild(newNode); //Adds a Node
doc.Save("temp.xml");
Dynamically add Picture box using C# delegate
The below code is just abstract just to show simple use of delegate
using System.Data;
using System.IO;
using System.Drawing;
using System.Text;
using System.Threading;
public partial class ImageView : Form{
Mydel a;
public delegate void Mydel(PictureBox p);
public ImageView(){
InitializeComponent();
}
private void ImageView_Load(object sender, EventArgs e){
a = new Mydel(Add);
Thread t = new Thread(load);
t.Start();
}
public void load(){
DirectoryInfo dinfo = new DirectoryInfo(@"F:\Mypics");
if (Image.FromFile(finfo[i].FullName) != null){ PictureBox p = new PictureBox();
Controls[Controls.IndexOf(panel1)].Invoke(a, obj);
if (x > this.Width-100){ y += 100;
}
} } public void Add(PictureBox p) { panel1.Controls.Add(p); } } }
FileInfo[] finfo = dinfo.GetFiles();
Graphics g = panel1.CreateGraphics();
int x = 20;
int y = 20;
for (int i = 0; i
p.Image = Image.FromFile(finfo[i].FullName);
p.SizeMode = PictureBoxSizeMode.StretchImage;
p.Left = x;
p.Top = y;
p.ImageLocation = finfo[i].FullName;
p.Width = 140;
p.Height = 90;
Object[] obj = new Object[1];
obj[0] = p;
x += 150;
x = 20;
}
if (i > 35)
break;