Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 11-09-2003, 02:34 PM   #1
Registered: Oct 2003
Location: Pico
Distribution: SUSE 9.1
Posts: 83

Rep: Reputation: 15
c++ [Char serch + Destroy]

Im making some code to take input from cin and basically search for the first string in a '
Thing is if I put any characters before it, it includes extra characters on the end (which varies depending on how far across the screen when the first ' is.
Here is my messy (unoptimized) code.

#include <iostream>
#include "scrf" //basically has functions getch() and clrscr()
#define TRUE 1
#define FALSE 0

typedef short unsigned int sint;

//function declarations
sint quit( void );
void takinchar( int justachar[] );

//define constants - using const not define
const sint cmdl = 100; //all string lengths

int main()
char line[cmdl] , prog[cmdl];
sint strc = FALSE , progx = 0;

std::cin >> line;
for ( sint chrl = 0 ; chrl <= cmdl ; chrl++ )
if (strc == TRUE)
prog[progx] = line[chrl];

if (line[chrl] == '\'')
if (strc == FALSE)
strc = TRUE;
else if (strc == TRUE)
{ prog[chrl-1] = '\0';
break; }

std::cout << "\nhere it is :" << prog << ":";

takinchar( prog );

return quit();

sint quit( void ) //Im QUITTING I AM
std::cout << "\nPress any key to exit";
std::cout << "\n\a";

return 0;

void takinchar( int progad[] )
//play with char here.


Also I know I cant return a string from a function, so who would I go about returning the adress of the string( references? ).

Old 11-09-2003, 03:23 PM   #2
Senior Member
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,565

Rep: Reputation: 140Reputation: 140

look at string.h or cstring

maybe this will help, good luck

Last edited by j-ray; 11-09-2003 at 03:24 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
C pointers confusion - char ** = char [][] ?? saravkrish Programming 12 12-02-2004 11:06 AM
C Problem---convert char to char* totti10 Programming 11 11-06-2004 12:32 PM
invalid conversion from `char' to `const char* bru Programming 6 05-09-2004 04:07 PM
convert from char* to unsigned char* D J Linux - Software 2 02-20-2004 05:09 AM
Copy a char* to another char* sathyan Programming 8 07-24-2003 07:15 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:59 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration