LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 10-12-2004, 07:32 PM   #1
saiz66
Member
 
Registered: Apr 2003
Posts: 225

Rep: Reputation: 30
[c] simple question


Hi. I wanted to know how I could start off a string from the second letter. An example would be better:

eg.

char mybuf[100];

mybuf = "Hi.";

I want it so it is:

mybuf = "i."

So basically I am starting off at the 2nd spot. Thanks!

Also i want to add that i know how to do it when it is
char * mybuf;

but is it possible to do it with

char mybuf[100]?

Last edited by saiz66; 10-12-2004 at 07:41 PM.
 
Old 10-12-2004, 08:03 PM   #2
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
I'm not exactly sure what you're trying to do, but does this answer your question?

Code:
itsme@itsme:~/C$ cat demo.c
#include <stdio.h>
#include <string.h>

int main(void)
{
  char buf[100] = "some string";

  puts(buf+1);
  strcpy(buf+4, "thing else");
  puts(buf);

  return 0;
}
itsme@itsme:~/C$ ./demo
ome string
something else
 
Old 10-12-2004, 08:55 PM   #3
saiz66
Member
 
Registered: Apr 2003
Posts: 225

Original Poster
Rep: Reputation: 30
thanks a lot!
 
  


Reply



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
Ubuntu Fluxbox simple question, simple answer? generallimptoes Linux - Software 3 09-26-2005 02:03 PM
Installing Programs - A simple question from my simple mind jmp875 Linux - Newbie 6 02-18-2004 09:03 PM
Hopefully a Simple Question Arcane Kidd Linux - Newbie 5 01-17-2003 04:27 PM
Really Simple Question -- Please help! Cia420 Linux - General 3 05-07-2002 06:42 AM
simple question seeking simple answer enzo250gto Linux - Newbie 1 10-27-2001 04:08 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:21 PM.

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