Need Help Running a program in C++ for Ubuntu (Linux)

Cam Tay
Messages
2
Reaction score
0

Homework Statement


m working on a Engineering Project and I'm having serious trouble trying to run this program in C++. I'm following an example of the program from Program done in C but I'm trying to convert it into C++. I'm going to link the example I'm following and what I'm doing trying to run it in C++. I want this to be able to run in Ubuntu (Linux) based system not for MSDOS (Microsoft) based system. If at all possible, could someone help me try to have this program example run in Ubuntu (Linux Based System) instead of MSDOS (Microsoft Based System)? Please Help.
-------------------------------------------------------------------------------------------------------------------------------------------

Homework Equations


This is the example I'm trying to follow from a C program to change it into C++

void main()
{
char c[10]={0},p[10],d[10]={0};
int i,l,k;
clrscr();
printf("Enter msg:");
gets(p);
printf("\n");
printf("Enter keysize:");
scanf("%d",&k);
puts(p);
for(i=0;i<10;i++)
{
if(p>=65 && p<=96)
{
c=((p-65+k)%26)+65;
}
else if(p>=97 && p<=122)
{
c=((p-97+k)%26)+97;
}
}
printf("\n");
puts(c);
for(i=0;i<10;i++)
{
if(c>=65 && c<=96)
{
if((c-65-k)<0)
{
d=c-k+26;
}
else
{
d=((c-65-k)%26)+65;
}
}
else if(c>=97 && c<=122)
{
if((c-97-k)<0)
{
d=c-k+26;
}
else
{
d=((c-97-k)%26)+97;
}
}
}
printf("\n");
puts(d);
getch();
}
[/B]

The Attempt at a Solution


This is my work example:
//hillciphering.cpp
//Deciphering a Message
//using Hill Ciphering
----------------------------------
#include <iostream>
#include <string>
using namespace std;

void main()
{

char c[10]={0},p[10],d[10]={0};
int i,l,k;

count << "Enter msg:";
cin >> p;
count << "\n";
count << "Enter Matrix Keysize:";
display("%d","&k");
puts(p);
for(i=0;i<10;i++)
{
if(p>=65 && p<=96)
{
c=((p-65+k)%26)+65;
}
else if(p>=97 && p<=122)
{
c=((p-97+k)%26)+97;
}
}
count << "\n";
puts(c);
for(i=0;i<10;i++)
{
if(c>=65 && c<=96)
{
if((c-65-k)<0)
{
d=c-k+26;
}
else
{
d=((c-65-k)%26)+65;
}
}
else if(c>=97 && c<=122)
{
if((c-97-k)<0)
{
d=c-k+26;
}
else
{
d=((c-97-k)%26)+97;
}
}
}
count<< "\n";
puts(d);
getch();
}
[/B]
 
Last edited by a moderator:
on Phys.org
1. Use [code][/code] tags to format your code, at the moment it is completely unreadable, as all references to [i] were treated as italic tags.

2. What have you tried, and what have happened? "I have a serious trouble" doesn't tell us anything about what kind of problems you are experiencing.
 
Well I'm trying to run it in Ubuntu but it's not running as I would it to in C program. I'm trying to change the few things in C to run it in C++ but it's not working too well for me. Where do I use code/code tags? I don't understand that. Please help
 
[code]int main()
{
return 0;
}[/code]

is displayed as

Code:
int main()
{
    return 0;
}

instead of unreadable

int main()
{
return 0;
}

You have still failed to explain what you are doing and what kind of problems you see. There are zillions of things that can go wrong, and not knowing what actions you take and what messages you see means we are not able to help.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 37 ·
2
Replies
37
Views
6K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 1 ·
Replies
1
Views
11K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 21 ·
Replies
21
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 17 ·
Replies
17
Views
3K