Click here to Skip to main content
15,921,959 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Convert float to double Pin
RaajaOfSelf23-Mar-03 22:00
RaajaOfSelf23-Mar-03 22:00 
GeneralRe: Convert float to double Pin
Jambolo25-Mar-03 17:03
Jambolo25-Mar-03 17:03 
GeneralRe: Convert float to double Pin
Reservoir Dog23-Mar-03 23:48
Reservoir Dog23-Mar-03 23:48 
GeneralSetting default font for CRichEditCtrl Pin
Ph@ntom23-Mar-03 20:22
Ph@ntom23-Mar-03 20:22 
GeneralDDI Hooking Pin
vikramlinux23-Mar-03 20:21
vikramlinux23-Mar-03 20:21 
GeneralWeb Browser Control Pin
Steven M Hunt23-Mar-03 16:02
Steven M Hunt23-Mar-03 16:02 
GeneralRe: Web Browser Control Pin
Neville Franks23-Mar-03 23:27
Neville Franks23-Mar-03 23:27 
Generalhelp with Dynamic allocation in C. Pin
mnjobes23-Mar-03 14:55
mnjobes23-Mar-03 14:55 
i've been working on this program (cryptology based) and just realized that the only way that it would be up to standards; would be to have a user defined lenght of the array of characters (captured by getchar() ). I am only in the 3rd month of my programming class, so we have not yet covered dynamic allocation (I don't know if we even will). I know that this is C++ but the people in C# said I should come here, you all are probably smarter anyway.
Long story-short. I need to capture an array of characters where, as the user types, the reallocation would be made; so no prompting of #'s just typing. here is how I tryed to do it but recived errors in execution, it does compile(What am I doing wrong??). I'm having a lot of trouble with this one. thanks bunches for your help Smile | :) .

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int char_to_num(char input);
void main (void){

char egrab,*cin;
int i,j,num,str_size;//, *t;

scanf("%c", &egrab); /*egrab grabs the enter from the previous
module this is a small part of my thing*/
printf("\nPlease enter the characters))>: ");
num = 0;
str_size=10;

cin= (char *)calloc(str_size, sizeof(char));

for(i=0; i<(i+1); i++,cin+=10)
{
for(j=0; j<10;j++,cin++){

*cin = getchar();
if (*cin =='\n')break;
num += 1;
}
if (*cin =='\n')break;
cin = (char *)realloc(cin, (sizeof(char)*10));

}
cin[i+j] = 0; /*close as to be printed as a string later*/

/*fill the array to be encrypted ( t[] ) with integer conversion*/

for(i=0; i<num;i++,t++,cin++){

*t="char_to_num(*cin);}

/*print" out="" the="" results="" as="" a="" check*=""

="" printf("\nnum="%d\n"," num);

="" for(i="0;" i<num;i++){
="" printf("%c",="" cin[i]);}

="" printf("\n");

="" i<num;i++,t++){
="" printf("%d="" ",="" *t);}

}="" *end*=""
="" ******************************************************************************************="" *this="" will="" convert="" character="" into="" number="" (67="" total="" possibilites)*=""

int="" char_to_num(char="" input){

="" int="" output;

="" if="" (="" (input="=" 'a')="" ||="" ){
="" output="1;}
" else="" if(="" 'b')="" 'c')="" 'd')="" 'e')="" 'f')="" 'g')="" 'h')="" 'i')="" 'j')="" 'k')="" 'l')="" 'm')="" 'n')="" 'o')="" 'p')="" 'q')="" 'r')="" 's')="" 't')="" 'u')="" 'v')="" 'w')="" 'x')="" 'y')="" 'z')="" input="=" '!'="" '@'="" '#'="" '$'="" '?'="" '^'="" '&'="" '*'="" '('="" ')'="" '-'="" '_'="" '=" ){
output = 39;}
else if( input == " +'="" '\\'="" '|'="" '`'="" '~'="" '.'="" ','="" '0'="" '1'="" '2'="" '3'="" '4'="" '5'="" '6'="" '7'="" '8'="" '9'="" '<'="">' ){
output = 59;}
else if( input == '[' ){
output = 60;}
else if( input == ']' ){
output = 61;}
else if( input == '{' ){
output = 62;}
else if( input == '}' ){
output = 63;}
else if( input == '/' ){
output = 64;}
else if( input == ';' ){
output = 65;}
else if( input == ':' ){
output = 66;}
else if( input == '%' ){
output = 0;}
else {
output = -1;}

return(output);
}

THANKS AGAIN.
GeneralRe: help with Dynamic allocation in C. Pin
Taka Muraoka23-Mar-03 15:11
Taka Muraoka23-Mar-03 15:11 
GeneralRe: help with Dynamic allocation in C. Pin
mnjobes23-Mar-03 19:09
mnjobes23-Mar-03 19:09 
GeneralRe: help with Dynamic allocation in C. Pin
Taka Muraoka23-Mar-03 19:16
Taka Muraoka23-Mar-03 19:16 
GeneralRe: help with Dynamic allocation in C. Pin
mnjobes26-Mar-03 20:32
mnjobes26-Mar-03 20:32 
GeneralRe: help with Dynamic allocation in C. Pin
Taka Muraoka26-Mar-03 21:10
Taka Muraoka26-Mar-03 21:10 
GeneralChanging the file extension for documents in VC7 Pin
Matt Gates23-Mar-03 14:21
Matt Gates23-Mar-03 14:21 
GeneralRe: Changing the file extension for documents in VC7 Pin
Nish Nishant23-Mar-03 20:00
sitebuilderNish Nishant23-Mar-03 20:00 
QuestionEmulating Win32 on Windows 98/Me? Pin
Ambit23-Mar-03 12:45
Ambit23-Mar-03 12:45 
AnswerRe: Emulating Win32 on Windows 98/Me? Pin
Taka Muraoka23-Mar-03 12:51
Taka Muraoka23-Mar-03 12:51 
GeneralRe: Emulating Win32 on Windows 98/Me? Pin
Ambit23-Mar-03 14:29
Ambit23-Mar-03 14:29 
GeneralRe: Emulating Win32 on Windows 98/Me? Pin
Taka Muraoka23-Mar-03 15:28
Taka Muraoka23-Mar-03 15:28 
GeneralRe: Emulating Win32 on Windows 98/Me? Pin
Ambit24-Mar-03 2:30
Ambit24-Mar-03 2:30 
AnswerRe: Emulating Win32 on Windows 98/Me? Pin
Stefan Pedersen23-Mar-03 12:52
Stefan Pedersen23-Mar-03 12:52 
GeneralRe: Emulating Win32 on Windows 98/Me? Pin
Ambit23-Mar-03 14:47
Ambit23-Mar-03 14:47 
GeneralRe: Emulating Win32 on Windows 98/Me? Pin
Stefan Pedersen23-Mar-03 23:36
Stefan Pedersen23-Mar-03 23:36 
AnswerRe: Emulating Win32 on Windows 98/Me? Pin
Dave Bryant23-Mar-03 13:52
Dave Bryant23-Mar-03 13:52 
GeneralRe: Emulating Win32 on Windows 98/Me? Pin
Ambit23-Mar-03 14:32
Ambit23-Mar-03 14:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.